Skip to content

Commit

Permalink
fix(50796): omit questionToken in object literal method completions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Sep 16, 2022
1 parent 3b84f76 commit 01cae69
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/completions.ts
Expand Up @@ -1171,7 +1171,7 @@ namespace ts.Completions {
/*modifiers*/ undefined,
typedParam.dotDotDotToken,
typedParam.name,
typedParam.questionToken,
/*questionToken*/ undefined,
/*type*/ undefined,
typedParam.initializer,
));
Expand Down
38 changes: 38 additions & 0 deletions tests/cases/fourslash/completionsObjectLiteralMethod5.ts
@@ -0,0 +1,38 @@
/// <reference path="fourslash.ts" />

// @newline: LF
// @Filename: a.ts
////interface Foo {
//// method(x?: string): void;
////}
////const foo: Foo = {
//// /*m*/
////}

verify.completions({
marker: "m",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithObjectLiteralMethodSnippets: true,
useLabelDetailsInCompletionEntries: true,
},
includes: [
{
name: "method",
sortText: completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "method"),
insertText: undefined,
},
{
name: "method",
sortText: completion.SortText.SortBelow(
completion.SortText.ObjectLiteralProperty(completion.SortText.LocationPriority, "method")),
source: completion.CompletionSource.ObjectLiteralMethodSnippet,
isSnippet: true,
insertText: "method(x) {\n $0\n},",
labelDetails: {
detail: "(x)",
},
},
],
});

0 comments on commit 01cae69

Please sign in to comment.