diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index d9553ea3465f9..951ad5e5bba87 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -3,7 +3,7 @@ namespace ts.formatting { export interface FormatContext { readonly options: FormatCodeSettings; readonly getRules: RulesMap; - readonly host?: FormattingHost; + readonly host: FormattingHost; } export interface TextRangeWithKind extends TextRange { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 2c551fe9d7c07..b1799167c437b 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2085,9 +2085,9 @@ namespace ts { /** * The default is CRLF. */ - export function getNewLineOrDefaultFromHost(host: FormattingHost | undefined, formatSettings?: FormatCodeSettings) { + export function getNewLineOrDefaultFromHost(host: FormattingHost, formatSettings?: FormatCodeSettings) { return formatSettings?.newLineCharacter || - host?.getNewLine?.() || + host.getNewLine?.() || carriageReturnLineFeed; }