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
…45391)

* Some cleanup around inlay hints types to get more-precise checking.

* Update Baselines and/or Applied Lint Fixes

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
  • Loading branch information
DanielRosenwasser and typescript-bot authored Aug 23, 2021
1 parent 7b0e665 commit a417917
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/harness/client.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
10 changes: 3 additions & 7 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5886,7 +5886,7 @@ declare namespace ts {
interface InlayHint {
text: string;
position: number;
kind?: InlayHintKind;
kind: InlayHintKind;
whitespaceBefore?: boolean;
whitespaceAfter?: boolean;
}
Expand Down Expand Up @@ -8739,11 +8739,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.
Expand All @@ -8761,7 +8757,7 @@ declare namespace ts.server.protocol {
interface InlayHintItem {
text: string;
position: Location;
kind?: InlayHintKind;
kind: InlayHintKind;
whitespaceBefore?: boolean;
whitespaceAfter?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5886,7 +5886,7 @@ declare namespace ts {
interface InlayHint {
text: string;
position: number;
kind?: InlayHintKind;
kind: InlayHintKind;
whitespaceBefore?: boolean;
whitespaceAfter?: boolean;
}
Expand Down

0 comments on commit a417917

Please sign in to comment.