File tree 3 files changed +7
-5
lines changed
3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ namespace ts.formatting {
3
3
export interface FormatContext {
4
4
readonly options : FormatCodeSettings ;
5
5
readonly getRules : RulesMap ;
6
- readonly host : FormattingHost ;
6
+ readonly host ? : FormattingHost ;
7
7
}
8
8
9
9
export interface TextRangeWithKind < T extends SyntaxKind = SyntaxKind > extends TextRange {
Original file line number Diff line number Diff line change @@ -203,15 +203,17 @@ namespace ts {
203
203
has ( dependencyName : string , inGroups ?: PackageJsonDependencyGroup ) : boolean ;
204
204
}
205
205
206
+ /** @internal */
206
207
export interface FormattingHost {
207
208
getNewLine ?( ) : string ;
208
209
}
209
210
210
211
//
211
212
// Public interface of the host of a language service instance.
212
213
//
213
- export interface LanguageServiceHost extends GetEffectiveTypeRootsHost , FormattingHost {
214
+ export interface LanguageServiceHost extends GetEffectiveTypeRootsHost {
214
215
getCompilationSettings ( ) : CompilerOptions ;
216
+ getNewLine ?( ) : string ;
215
217
getProjectVersion ?( ) : string ;
216
218
getScriptFileNames ( ) : string [ ] ;
217
219
getScriptKind ?( fileName : string ) : ScriptKind ;
Original file line number Diff line number Diff line change @@ -2085,9 +2085,9 @@ namespace ts {
2085
2085
/**
2086
2086
* The default is CRLF.
2087
2087
*/
2088
- export function getNewLineOrDefaultFromHost ( host : FormattingHost , formatSettings ?: FormatCodeSettings ) {
2089
- return ( formatSettings && formatSettings . newLineCharacter ) ||
2090
- ( host . getNewLine && host . getNewLine ( ) ) ||
2088
+ export function getNewLineOrDefaultFromHost ( host : FormattingHost | undefined , formatSettings ?: FormatCodeSettings ) {
2089
+ return formatSettings ? .newLineCharacter ||
2090
+ host ? .getNewLine ?. ( ) ||
2091
2091
carriageReturnLineFeed ;
2092
2092
}
2093
2093
You can’t perform that action at this time.
0 commit comments