mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
fix(47081): show completion list in parenthesized object literal arguments (#47104)
This commit is contained in:
parent
8907d7a675
commit
49a12dcbbb
@ -3913,9 +3913,14 @@ namespace ts.Completions {
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
if (isBinaryExpression(node.parent) && node.parent.operatorToken.kind === SyntaxKind.EqualsToken && node === node.parent.left) {
|
||||
const parent = walkUpParenthesizedExpressions(node.parent);
|
||||
if (isBinaryExpression(parent) && parent.operatorToken.kind === SyntaxKind.EqualsToken && node === parent.left) {
|
||||
// Object literal is assignment pattern: ({ | } = x)
|
||||
return typeChecker.getTypeAtLocation(node.parent);
|
||||
return typeChecker.getTypeAtLocation(parent);
|
||||
}
|
||||
if (isExpression(parent)) {
|
||||
// f(() => (({ | })));
|
||||
return typeChecker.getContextualType(parent);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
17
tests/cases/fourslash/completionListInObjectLiteral7.ts
Normal file
17
tests/cases/fourslash/completionListInObjectLiteral7.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////type Foo = { foo: boolean };
|
||||
////function f<T>(shape: Foo): any;
|
||||
////function f<T>(shape: () => Foo): any;
|
||||
////function f(arg: any) {
|
||||
//// return arg;
|
||||
////}
|
||||
////
|
||||
////f({ /*1*/ });
|
||||
////f(() => ({ /*2*/ }));
|
||||
////f(() => (({ /*3*/ })));
|
||||
|
||||
verify.completions({
|
||||
marker: ["1", "2", "3"],
|
||||
exact: ["foo"]
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user