mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
feat(48743): allow autocompletion in parameter object destructuring in JavaScript (#48757)
This commit is contained in:
@@ -3062,7 +3062,7 @@ namespace ts.Completions {
|
||||
// through type declaration or inference.
|
||||
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
|
||||
// type of parameter will flow in from the contextual type of the function
|
||||
let canGetType = hasInitializer(rootDeclaration) || hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement;
|
||||
let canGetType = hasInitializer(rootDeclaration) || !!getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement;
|
||||
if (!canGetType && rootDeclaration.kind === SyntaxKind.Parameter) {
|
||||
if (isExpression(rootDeclaration.parent)) {
|
||||
canGetType = !!typeChecker.getContextualType(rootDeclaration.parent as Expression);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
|
||||
// @filename: a.js
|
||||
/////**
|
||||
//// * @typedef Foo
|
||||
//// * @property {number} a
|
||||
//// * @property {string} b
|
||||
//// */
|
||||
////
|
||||
/////**
|
||||
//// * @param {Foo} options
|
||||
//// */
|
||||
////function f({ /**/ }) {}
|
||||
|
||||
verify.completions({ marker: "", exact: ["a", "b"] });
|
||||
Reference in New Issue
Block a user