Skip to content

Commit 3442151

Browse files
authored
completion for return const assertion. (microsoft#41475)
1 parent bce412c commit 3442151

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24423,10 +24423,7 @@ namespace ts {
2442324423
return undefined;
2442424424

2442524425
function tryFindWhenConstTypeReference(node: Expression) {
24426-
if(isCallLikeExpression(node.parent)){
24427-
return getContextualTypeForArgument(node.parent, node);
24428-
}
24429-
return undefined;
24426+
return getContextualType(node);
2443024427
}
2443124428
}
2443224429

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
4+
//// type T = {
5+
//// foo1: 1;
6+
//// foo2: 2;
7+
//// }
8+
//// function F(x: ()=>T) {}
9+
//// F(()=>({/*1*/} as const))
10+
11+
verify.completions({
12+
marker: "1",
13+
exact: [
14+
{ name: "foo1", text: "(property) foo1: 1" },
15+
{ name: "foo2", text: "(property) foo2: 2" },
16+
],
17+
});

0 commit comments

Comments
 (0)