Skip to content

Commit d0e1255

Browse files
authored
Merge InlayHintOptions into UserPreferences (#47729)
* get rid of inlayhintoptions * update userpreferences in protocol
1 parent 0798faf commit d0e1255

File tree

11 files changed

+47
-39
lines changed

11 files changed

+47
-39
lines changed

src/compiler/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8693,6 +8693,13 @@ namespace ts {
86938693
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
86948694
readonly provideRefactorNotApplicableReason?: boolean;
86958695
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
8696+
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
8697+
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
8698+
readonly includeInlayFunctionParameterTypeHints?: boolean,
8699+
readonly includeInlayVariableTypeHints?: boolean;
8700+
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
8701+
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
8702+
readonly includeInlayEnumMemberValueHints?: boolean;
86968703
}
86978704

86988705
/** Represents a bigint literal value without requiring bigint support */

src/harness/fourslashImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ namespace FourSlash {
841841
});
842842
}
843843

844-
public verifyInlayHints(expected: readonly FourSlashInterface.VerifyInlayHintsOptions[], span: ts.TextSpan = { start: 0, length: this.activeFile.content.length }, preference?: ts.InlayHintsOptions) {
844+
public verifyInlayHints(expected: readonly FourSlashInterface.VerifyInlayHintsOptions[], span: ts.TextSpan = { start: 0, length: this.activeFile.content.length }, preference?: ts.UserPreferences) {
845845
const hints = this.languageService.provideInlayHints(this.activeFile.fileName, span, preference);
846846
assert.equal(hints.length, expected.length, "Number of hints");
847847

src/harness/fourslashInterfaceImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ namespace FourSlashInterface {
255255
}
256256
}
257257

258-
public getInlayHints(expected: readonly VerifyInlayHintsOptions[], span: ts.TextSpan, preference?: ts.InlayHintsOptions) {
258+
public getInlayHints(expected: readonly VerifyInlayHintsOptions[], span: ts.TextSpan, preference?: ts.UserPreferences) {
259259
this.state.verifyInlayHints(expected, span, preference);
260260
}
261261

src/harness/harnessLanguageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ namespace Harness.LanguageService {
600600
provideCallHierarchyOutgoingCalls(fileName: string, position: number) {
601601
return unwrapJSONCallResult(this.shim.provideCallHierarchyOutgoingCalls(fileName, position));
602602
}
603-
provideInlayHints(fileName: string, span: ts.TextSpan, preference: ts.InlayHintsOptions) {
603+
provideInlayHints(fileName: string, span: ts.TextSpan, preference: ts.UserPreferences) {
604604
return unwrapJSONCallResult(this.shim.provideInlayHints(fileName, span, preference));
605605
}
606606
getEmitOutput(fileName: string): ts.EmitOutput {

src/server/protocol.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,6 +3420,14 @@ namespace ts.server.protocol {
34203420

34213421
readonly displayPartsForJSDoc?: boolean;
34223422
readonly generateReturnInDocTemplate?: boolean;
3423+
3424+
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
3425+
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
3426+
readonly includeInlayFunctionParameterTypeHints?: boolean,
3427+
readonly includeInlayVariableTypeHints?: boolean;
3428+
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
3429+
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
3430+
readonly includeInlayEnumMemberValueHints?: boolean;
34233431
}
34243432

34253433
export interface CompilerOptions {

src/services/inlayHints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace ts.InlayHints {
77
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
88
};
99

10-
function shouldShowParameterNameHints(preferences: InlayHintsOptions) {
10+
function shouldShowParameterNameHints(preferences: UserPreferences) {
1111
return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all";
1212
}
1313

14-
function shouldShowLiteralParameterNameHintsOnly(preferences: InlayHintsOptions) {
14+
function shouldShowLiteralParameterNameHintsOnly(preferences: UserPreferences) {
1515
return preferences.includeInlayParameterNameHints === "literals";
1616
}
1717

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ namespace ts {
26362636
return declaration ? CallHierarchy.getOutgoingCalls(program, declaration) : [];
26372637
}
26382638

2639-
function provideInlayHints(fileName: string, span: TextSpan, preferences: InlayHintsOptions = emptyOptions): InlayHint[] {
2639+
function provideInlayHints(fileName: string, span: TextSpan, preferences: UserPreferences = emptyOptions): InlayHint[] {
26402640
synchronizeHostData();
26412641
const sourceFile = getValidSourceFile(fileName);
26422642
return InlayHints.provideInlayHints(getInlayHintsContext(sourceFile, span, preferences));

src/services/shims.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ namespace ts {
282282
prepareCallHierarchy(fileName: string, position: number): string;
283283
provideCallHierarchyIncomingCalls(fileName: string, position: number): string;
284284
provideCallHierarchyOutgoingCalls(fileName: string, position: number): string;
285-
provideInlayHints(fileName: string, span: TextSpan, preference: InlayHintsOptions | undefined): string;
285+
provideInlayHints(fileName: string, span: TextSpan, preference: UserPreferences | undefined): string;
286286
getEmitOutput(fileName: string): string;
287287
getEmitOutputObject(fileName: string): EmitOutput;
288288

@@ -1069,7 +1069,7 @@ namespace ts {
10691069
);
10701070
}
10711071

1072-
public provideInlayHints(fileName: string, span: TextSpan, preference: InlayHintsOptions | undefined): string {
1072+
public provideInlayHints(fileName: string, span: TextSpan, preference: UserPreferences | undefined): string {
10731073
return this.forwardJSONCall(
10741074
`provideInlayHints('${fileName}', '${JSON.stringify(span)}', ${JSON.stringify(preference)})`,
10751075
() => this.languageService.provideInlayHints(fileName, span, preference)

src/services/types.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -585,16 +585,6 @@ namespace ts {
585585
includeInsertTextCompletions?: boolean;
586586
}
587587

588-
export interface InlayHintsOptions extends UserPreferences {
589-
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
590-
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
591-
readonly includeInlayFunctionParameterTypeHints?: boolean,
592-
readonly includeInlayVariableTypeHints?: boolean;
593-
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
594-
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
595-
readonly includeInlayEnumMemberValueHints?: boolean;
596-
}
597-
598588
export type SignatureHelpTriggerCharacter = "," | "(" | "<";
599589
export type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
600590

@@ -1620,6 +1610,6 @@ namespace ts {
16201610
cancellationToken: CancellationToken;
16211611
host: LanguageServiceHost;
16221612
span: TextSpan;
1623-
preferences: InlayHintsOptions;
1613+
preferences: UserPreferences;
16241614
}
16251615
}

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,6 +4058,13 @@ declare namespace ts {
40584058
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
40594059
readonly provideRefactorNotApplicableReason?: boolean;
40604060
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
4061+
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
4062+
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
4063+
readonly includeInlayFunctionParameterTypeHints?: boolean;
4064+
readonly includeInlayVariableTypeHints?: boolean;
4065+
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
4066+
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
4067+
readonly includeInlayEnumMemberValueHints?: boolean;
40614068
}
40624069
/** Represents a bigint literal value without requiring bigint support */
40634070
export interface PseudoBigInt {
@@ -5882,15 +5889,6 @@ declare namespace ts {
58825889
/** @deprecated Use includeCompletionsWithInsertText */
58835890
includeInsertTextCompletions?: boolean;
58845891
}
5885-
interface InlayHintsOptions extends UserPreferences {
5886-
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
5887-
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
5888-
readonly includeInlayFunctionParameterTypeHints?: boolean;
5889-
readonly includeInlayVariableTypeHints?: boolean;
5890-
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
5891-
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
5892-
readonly includeInlayEnumMemberValueHints?: boolean;
5893-
}
58945892
type SignatureHelpTriggerCharacter = "," | "(" | "<";
58955893
type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
58965894
interface SignatureHelpItemsOptions {
@@ -6694,7 +6692,7 @@ declare namespace ts {
66946692
cancellationToken: CancellationToken;
66956693
host: LanguageServiceHost;
66966694
span: TextSpan;
6697-
preferences: InlayHintsOptions;
6695+
preferences: UserPreferences;
66986696
}
66996697
}
67006698
declare namespace ts {
@@ -9572,6 +9570,13 @@ declare namespace ts.server.protocol {
95729570
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
95739571
readonly displayPartsForJSDoc?: boolean;
95749572
readonly generateReturnInDocTemplate?: boolean;
9573+
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
9574+
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
9575+
readonly includeInlayFunctionParameterTypeHints?: boolean;
9576+
readonly includeInlayVariableTypeHints?: boolean;
9577+
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
9578+
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
9579+
readonly includeInlayEnumMemberValueHints?: boolean;
95759580
}
95769581
interface CompilerOptions {
95779582
allowJs?: boolean;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,6 +4058,13 @@ declare namespace ts {
40584058
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
40594059
readonly provideRefactorNotApplicableReason?: boolean;
40604060
readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none";
4061+
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
4062+
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
4063+
readonly includeInlayFunctionParameterTypeHints?: boolean;
4064+
readonly includeInlayVariableTypeHints?: boolean;
4065+
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
4066+
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
4067+
readonly includeInlayEnumMemberValueHints?: boolean;
40614068
}
40624069
/** Represents a bigint literal value without requiring bigint support */
40634070
export interface PseudoBigInt {
@@ -5882,15 +5889,6 @@ declare namespace ts {
58825889
/** @deprecated Use includeCompletionsWithInsertText */
58835890
includeInsertTextCompletions?: boolean;
58845891
}
5885-
interface InlayHintsOptions extends UserPreferences {
5886-
readonly includeInlayParameterNameHints?: "none" | "literals" | "all";
5887-
readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
5888-
readonly includeInlayFunctionParameterTypeHints?: boolean;
5889-
readonly includeInlayVariableTypeHints?: boolean;
5890-
readonly includeInlayPropertyDeclarationTypeHints?: boolean;
5891-
readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
5892-
readonly includeInlayEnumMemberValueHints?: boolean;
5893-
}
58945892
type SignatureHelpTriggerCharacter = "," | "(" | "<";
58955893
type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
58965894
interface SignatureHelpItemsOptions {
@@ -6694,7 +6692,7 @@ declare namespace ts {
66946692
cancellationToken: CancellationToken;
66956693
host: LanguageServiceHost;
66966694
span: TextSpan;
6697-
preferences: InlayHintsOptions;
6695+
preferences: UserPreferences;
66986696
}
66996697
}
67006698
declare namespace ts {

0 commit comments

Comments
 (0)