File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -23425,7 +23425,7 @@ namespace ts {
23425
23425
return getContextualTypeForArgument(<CallExpression | NewExpression>parent, node);
23426
23426
case SyntaxKind.TypeAssertionExpression:
23427
23427
case SyntaxKind.AsExpression:
23428
- return isConstTypeReference((<AssertionExpression>parent).type) ? undefined : getTypeFromTypeNode((<AssertionExpression>parent).type);
23428
+ return isConstTypeReference((<AssertionExpression>parent).type) ? tryFindWhenConstTypeReference(<AssertionExpression>parent) : getTypeFromTypeNode((<AssertionExpression>parent).type);
23429
23429
case SyntaxKind.BinaryExpression:
23430
23430
return getContextualTypeForBinaryOperand(node, contextFlags);
23431
23431
case SyntaxKind.PropertyAssignment:
@@ -23458,6 +23458,13 @@ namespace ts {
23458
23458
return getContextualJsxElementAttributesType(<JsxOpeningLikeElement>parent, contextFlags);
23459
23459
}
23460
23460
return undefined;
23461
+
23462
+ function tryFindWhenConstTypeReference(node: Expression) {
23463
+ if(isCallLikeExpression(node.parent)){
23464
+ return getContextualTypeForArgument(node.parent, node);
23465
+ }
23466
+ return undefined;
23467
+ }
23461
23468
}
23462
23469
23463
23470
function getInferenceContext(node: Node) {
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ ////type T = {
4
+ //// a: 1;
5
+ //// b: 2;
6
+ //// }
7
+ ////function F(x: T) {
8
+ //// }
9
+ ////F({/*1*/} as const)
10
+
11
+ verify . completions ( {
12
+ marker : "1" ,
13
+ exact : [
14
+ { name : "a" , text : "(property) a: 1" } ,
15
+ { name : "b" , text : "(property) b: 2" } ,
16
+ ] ,
17
+ } ) ;
You can’t perform that action at this time.
0 commit comments