Skip to content

Commit

Permalink
Some cleanup around inlay hints types to get more-precise checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser committed Aug 21, 2021
1 parent 08358f3 commit a2cefc5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/harness/client.ts
Expand Up @@ -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),
}));
}
Expand Down
8 changes: 2 additions & 6 deletions src/server/protocol.ts
Expand Up @@ -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 {
/**
Expand All @@ -2587,7 +2583,7 @@ namespace ts.server.protocol {
export interface InlayHintItem {
text: string;
position: Location;
kind?: InlayHintKind;
kind: InlayHintKind;
whitespaceBefore?: boolean;
whitespaceAfter?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/session.ts
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/services/types.ts
Expand Up @@ -720,7 +720,7 @@ namespace ts {
export interface InlayHint {
text: string;
position: number;
kind?: InlayHintKind;
kind: InlayHintKind;
whitespaceBefore?: boolean;
whitespaceAfter?: boolean;
}
Expand Down

0 comments on commit a2cefc5

Please sign in to comment.