Skip to content

Commit bce9e2c

Browse files
authored
Merge pull request #29250 from Microsoft/hasContextSensitiveReturnExpression
Fix function declaration without body to be checked as context sensitive
2 parents 8dff98d + f4a6fb7 commit bce9e2c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11040,8 +11040,7 @@ namespace ts {
1104011040

1104111041
function hasContextSensitiveReturnExpression(node: FunctionLikeDeclaration) {
1104211042
// TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
11043-
const body = node.body!;
11044-
return body.kind === SyntaxKind.Block ? false : isContextSensitive(body);
11043+
return !!node.body && node.body.kind !== SyntaxKind.Block && isContextSensitive(node.body);
1104511044
}
1104611045

1104711046
function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////interface ProxyHandler<T extends object> {
4+
//// getPrototypeOf?(target: T): object | null;
5+
////}
6+
////interface ProxyConstructor {
7+
//// new <T extends object>(target: T, handler: ProxyHandler<T>): T;
8+
////}
9+
////declare var Proxy: ProxyConstructor;
10+
////let target = {}
11+
////let proxy = new /**/Proxy(target, {
12+
//// getPrototypeOf()
13+
////})
14+
15+
goTo.marker("");
16+
verify.quickInfoExists();

0 commit comments

Comments
 (0)