Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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