diff --git a/src/harness/client.ts b/src/harness/client.ts index c72cfe681a725..aa40bcdb55f3f 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -653,7 +653,7 @@ namespace ts.server { return response.body!.map(item => ({ // TODO: GH#18217 ...item, - kind: item.kind as InlayHintKind | undefined, + kind: item.kind as InlayHintKind, position: this.lineOffsetToPosition(file, item.position), })); } diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 661639479aafa..6147077051b52 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2562,11 +2562,7 @@ namespace ts.server.protocol { body?: SignatureHelpItems; } - export const enum InlayHintKind { - Type = "Type", - Parameter = "Parameter", - Enum = "Enum", - } + export type InlayHintKind = "Type" | "Parameter" | "Enum"; export interface InlayHintsRequestArgs extends FileRequestArgs { /** @@ -2587,7 +2583,7 @@ namespace ts.server.protocol { export interface InlayHintItem { text: string; position: Location; - kind?: InlayHintKind; + kind: InlayHintKind; whitespaceBefore?: boolean; whitespaceAfter?: boolean; } diff --git a/src/server/session.ts b/src/server/session.ts index f08d809a171d3..6ab9500db2352 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1452,7 +1452,7 @@ namespace ts.server { }); } - private provideInlayHints(args: protocol.InlayHintsRequestArgs) { + private provideInlayHints(args: protocol.InlayHintsRequestArgs): readonly protocol.InlayHintItem[] { const { file, project } = this.getFileAndProject(args); const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!; const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file)); diff --git a/src/services/types.ts b/src/services/types.ts index 4ad9ddfa88946..0e5d95a15e971 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -720,7 +720,7 @@ namespace ts { export interface InlayHint { text: string; position: number; - kind?: InlayHintKind; + kind: InlayHintKind; whitespaceBefore?: boolean; whitespaceAfter?: boolean; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 6ca4baa8cbb41..876553628398e 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -5887,7 +5887,7 @@ declare namespace ts { interface InlayHint { text: string; position: number; - kind?: InlayHintKind; + kind: InlayHintKind; whitespaceBefore?: boolean; whitespaceAfter?: boolean; } @@ -8740,11 +8740,7 @@ declare namespace ts.server.protocol { interface SignatureHelpResponse extends Response { body?: SignatureHelpItems; } - enum InlayHintKind { - Type = "Type", - Parameter = "Parameter", - Enum = "Enum" - } + type InlayHintKind = "Type" | "Parameter" | "Enum"; interface InlayHintsRequestArgs extends FileRequestArgs { /** * Start position of the span. @@ -8762,7 +8758,7 @@ declare namespace ts.server.protocol { interface InlayHintItem { text: string; position: Location; - kind?: InlayHintKind; + kind: InlayHintKind; whitespaceBefore?: boolean; whitespaceAfter?: boolean; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index fea14c1fcb999..dc5a6420faa10 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -5887,7 +5887,7 @@ declare namespace ts { interface InlayHint { text: string; position: number; - kind?: InlayHintKind; + kind: InlayHintKind; whitespaceBefore?: boolean; whitespaceAfter?: boolean; }