diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa0091f99523a..4d14d50d6a490 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23408,7 +23408,7 @@ namespace ts { return getContextualTypeForArgument(parent, node); case SyntaxKind.TypeAssertionExpression: case SyntaxKind.AsExpression: - return isConstTypeReference((parent).type) ? undefined : getTypeFromTypeNode((parent).type); + return isConstTypeReference((parent).type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node, contextFlags); case SyntaxKind.PropertyAssignment: @@ -23441,6 +23441,13 @@ namespace ts { return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; + + function tryFindWhenConstTypeReference(node: Expression) { + if(isCallLikeExpression(node.parent)){ + return getContextualTypeForArgument(node.parent, node); + } + return undefined; + } } function getInferenceContext(node: Node) { diff --git a/tests/cases/fourslash/memberListInFunctionCall2.ts b/tests/cases/fourslash/memberListInFunctionCall2.ts new file mode 100644 index 0000000000000..5eb117b58f9cd --- /dev/null +++ b/tests/cases/fourslash/memberListInFunctionCall2.ts @@ -0,0 +1,17 @@ +/// + +////type T = { +//// a: 1; +//// b: 2; +////} +////function F(x: T) { +////} +////F({/*1*/} as const) + +verify.completions({ + marker: "1", + exact: [ + { name: "a", text: "(property) a: 1" }, + { name: "b", text: "(property) b: 2" }, + ], +});