Skip to content

Commit 717a1be

Browse files
authored
feat(48743): allow autocompletion in parameter object destructuring in JavaScript (#48757)
1 parent d45012c commit 717a1be

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/services/completions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,7 @@ namespace ts.Completions {
30623062
// through type declaration or inference.
30633063
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
30643064
// type of parameter will flow in from the contextual type of the function
3065-
let canGetType = hasInitializer(rootDeclaration) || hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement;
3065+
let canGetType = hasInitializer(rootDeclaration) || !!getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement;
30663066
if (!canGetType && rootDeclaration.kind === SyntaxKind.Parameter) {
30673067
if (isExpression(rootDeclaration.parent)) {
30683068
canGetType = !!typeChecker.getContextualType(rootDeclaration.parent as Expression);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
6+
// @filename: a.js
7+
/////**
8+
//// * @typedef Foo
9+
//// * @property {number} a
10+
//// * @property {string} b
11+
//// */
12+
////
13+
/////**
14+
//// * @param {Foo} options
15+
//// */
16+
////function f({ /**/ }) {}
17+
18+
verify.completions({ marker: "", exact: ["a", "b"] });

0 commit comments

Comments
 (0)