mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
autocomplete works for const assertion. (#39412)
* fix 39384 * add test
This commit is contained in:
parent
9a5c0074aa
commit
f29e03eea5
@ -23425,7 +23425,7 @@ namespace ts {
|
||||
return getContextualTypeForArgument(<CallExpression | NewExpression>parent, node);
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
return isConstTypeReference((<AssertionExpression>parent).type) ? undefined : getTypeFromTypeNode((<AssertionExpression>parent).type);
|
||||
return isConstTypeReference((<AssertionExpression>parent).type) ? tryFindWhenConstTypeReference(<AssertionExpression>parent) : getTypeFromTypeNode((<AssertionExpression>parent).type);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return getContextualTypeForBinaryOperand(node, contextFlags);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
@ -23458,6 +23458,13 @@ namespace ts {
|
||||
return getContextualJsxElementAttributesType(<JsxOpeningLikeElement>parent, contextFlags);
|
||||
}
|
||||
return undefined;
|
||||
|
||||
function tryFindWhenConstTypeReference(node: Expression) {
|
||||
if(isCallLikeExpression(node.parent)){
|
||||
return getContextualTypeForArgument(node.parent, node);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function getInferenceContext(node: Node) {
|
||||
|
||||
17
tests/cases/fourslash/memberListInFunctionCall2.ts
Normal file
17
tests/cases/fourslash/memberListInFunctionCall2.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////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" },
|
||||
],
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user