diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9a71a6a0277e8..96444d67efa0d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24250,10 +24250,7 @@ namespace ts { return undefined; function tryFindWhenConstTypeReference(node: Expression) { - if(isCallLikeExpression(node.parent)){ - return getContextualTypeForArgument(node.parent, node); - } - return undefined; + return getContextualType(node); } } diff --git a/tests/cases/fourslash/completionReturnConstAssertion.ts b/tests/cases/fourslash/completionReturnConstAssertion.ts new file mode 100644 index 0000000000000..addb207bf65e3 --- /dev/null +++ b/tests/cases/fourslash/completionReturnConstAssertion.ts @@ -0,0 +1,17 @@ +/// + + +//// type T = { +//// foo1: 1; +//// foo2: 2; +//// } +//// function F(x: ()=>T) {} +//// F(()=>({/*1*/} as const)) + +verify.completions({ + marker: "1", + exact: [ + { name: "foo1", text: "(property) foo1: 1" }, + { name: "foo2", text: "(property) foo2: 2" }, + ], +});