Skip to content

Commit 159b3dc

Browse files
Accepted baselines and updated fourslash test.
1 parent 9651c42 commit 159b3dc

File tree

3 files changed

+92
-10
lines changed

3 files changed

+92
-10
lines changed

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

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10055,12 +10055,42 @@ declare namespace ts {
1005510055
includeInsertTextCompletions?: boolean;
1005610056
}
1005710057
type SignatureHelpTriggerCharacter = "," | "(" | "<";
10058+
type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
1005810059
interface SignatureHelpItemsOptions {
10060+
triggerReason?: SignatureHelpTriggerReason;
10061+
}
10062+
type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason;
10063+
/**
10064+
* Signals that the user manually requested signature help.
10065+
* The language service will unconditionally attempt to provide a result.
10066+
*/
10067+
interface SignatureHelpInvokedReason {
10068+
kind: "invoked";
10069+
triggerCharacter?: undefined;
10070+
}
10071+
/**
10072+
* Signals that the signature help request came from a user typing a character.
10073+
* Depending on the character and the syntactic context, the request may or may not be served a result.
10074+
*/
10075+
interface SignatureHelpCharacterTypedReason {
10076+
kind: "characterTyped";
1005910077
/**
10060-
* If the editor is asking for signature help because a certain character was typed
10061-
* (as opposed to when the user explicitly requested them) this should be set.
10078+
* Character that was responsible for triggering signature help.
1006210079
*/
10063-
triggerCharacter?: SignatureHelpTriggerCharacter;
10080+
triggerCharacter: SignatureHelpTriggerCharacter;
10081+
}
10082+
/**
10083+
* Signals that this signature help request came from typing a character or moving the cursor.
10084+
* This should only occur if a signature help session was already active and the editor needs to see if it should adjust.
10085+
* The language service will unconditionally attempt to provide a result.
10086+
* `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move.
10087+
*/
10088+
interface SignatureHelpRetriggeredReason {
10089+
kind: "retrigger";
10090+
/**
10091+
* Character that was responsible for triggering signature help.
10092+
*/
10093+
triggerCharacter?: SignatureHelpRetriggerCharacter;
1006410094
}
1006510095
interface ApplyCodeActionCommandResult {
1006610096
successMessage: string;
@@ -11242,7 +11272,7 @@ declare namespace ts.Rename {
1124211272
function getRenameInfo(program: Program, sourceFile: SourceFile, position: number): RenameInfo;
1124311273
}
1124411274
declare namespace ts.SignatureHelp {
11245-
function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, triggerCharacter: SignatureHelpTriggerCharacter | undefined, cancellationToken: CancellationToken): SignatureHelpItems | undefined;
11275+
function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, triggerReason: SignatureHelpTriggerReason | undefined, cancellationToken: CancellationToken): SignatureHelpItems | undefined;
1124611276
interface ArgumentInfoForCompletions {
1124711277
readonly invocation: CallLikeExpression;
1124811278
readonly argumentIndex: number;
@@ -12973,8 +13003,22 @@ declare namespace ts.server.protocol {
1297313003
argumentCount: number;
1297413004
}
1297513005
type SignatureHelpTriggerCharacter = "," | "(" | "<";
13006+
type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
1297613007
interface SignatureHelpRequestArgs extends FileLocationRequestArgs {
12977-
triggerCharacter?: SignatureHelpTriggerCharacter;
13008+
triggerReason?: SignatureHelpTriggerReason;
13009+
}
13010+
type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason;
13011+
interface SignatureHelpInvokedReason {
13012+
kind: "invoked";
13013+
triggerCharacter?: undefined;
13014+
}
13015+
interface SignatureHelpCharacterTypedReason {
13016+
kind: "characterTyped";
13017+
triggerCharacter: SignatureHelpTriggerCharacter;
13018+
}
13019+
interface SignatureHelpRetriggeredReason {
13020+
kind: "retrigger";
13021+
triggerCharacter?: SignatureHelpRetriggerCharacter;
1297813022
}
1297913023
interface SignatureHelpRequest extends FileLocationRequest {
1298013024
command: CommandTypes.SignatureHelp;

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

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4807,12 +4807,42 @@ declare namespace ts {
48074807
includeInsertTextCompletions?: boolean;
48084808
}
48094809
type SignatureHelpTriggerCharacter = "," | "(" | "<";
4810+
type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")";
48104811
interface SignatureHelpItemsOptions {
4812+
triggerReason?: SignatureHelpTriggerReason;
4813+
}
4814+
type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason;
4815+
/**
4816+
* Signals that the user manually requested signature help.
4817+
* The language service will unconditionally attempt to provide a result.
4818+
*/
4819+
interface SignatureHelpInvokedReason {
4820+
kind: "invoked";
4821+
triggerCharacter?: undefined;
4822+
}
4823+
/**
4824+
* Signals that the signature help request came from a user typing a character.
4825+
* Depending on the character and the syntactic context, the request may or may not be served a result.
4826+
*/
4827+
interface SignatureHelpCharacterTypedReason {
4828+
kind: "characterTyped";
48114829
/**
4812-
* If the editor is asking for signature help because a certain character was typed
4813-
* (as opposed to when the user explicitly requested them) this should be set.
4830+
* Character that was responsible for triggering signature help.
4831+
*/
4832+
triggerCharacter: SignatureHelpTriggerCharacter;
4833+
}
4834+
/**
4835+
* Signals that this signature help request came from typing a character or moving the cursor.
4836+
* This should only occur if a signature help session was already active and the editor needs to see if it should adjust.
4837+
* The language service will unconditionally attempt to provide a result.
4838+
* `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move.
4839+
*/
4840+
interface SignatureHelpRetriggeredReason {
4841+
kind: "retrigger";
4842+
/**
4843+
* Character that was responsible for triggering signature help.
48144844
*/
4815-
triggerCharacter?: SignatureHelpTriggerCharacter;
4845+
triggerCharacter?: SignatureHelpRetriggerCharacter;
48164846
}
48174847
interface ApplyCodeActionCommandResult {
48184848
successMessage: string;

tests/cases/fourslash/signatureHelpFilteredTriggerCharacters01.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
goTo.marker();
1010
for (const triggerCharacter of ["<", "(", ","]) {
1111
edit.insert(triggerCharacter);
12-
verify.noSignatureHelpForTriggerCharacter(triggerCharacter);
12+
verify.noSignatureHelpForTriggerReason({
13+
kind: "characterTyped",
14+
triggerCharacter,
15+
});
16+
verify.signatureHelpPresentForTriggerReason({
17+
kind: "retrigger",
18+
triggerCharacter,
19+
});
1320
edit.backspace();
1421
}
15-
verify.signatureHelp({ triggerCharacter: undefined });
22+
verify.signatureHelpPresentForTriggerReason(/*triggerReason*/ undefined);
23+
verify.signatureHelpPresentForTriggerReason({ kind: "invoked" });

0 commit comments

Comments
 (0)