diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 20e6310f771..54f878ebef0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11040,8 +11040,7 @@ namespace ts { function hasContextSensitiveReturnExpression(node: FunctionLikeDeclaration) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - const body = node.body!; - return body.kind === SyntaxKind.Block ? false : isContextSensitive(body); + return !node.body || node.body.kind === SyntaxKind.Block ? false : isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration { diff --git a/tests/cases/fourslash/quickInfoTypeArgumentInferenceWithMethodWithoutBody.ts b/tests/cases/fourslash/quickInfoTypeArgumentInferenceWithMethodWithoutBody.ts new file mode 100644 index 00000000000..82cdd8882e2 --- /dev/null +++ b/tests/cases/fourslash/quickInfoTypeArgumentInferenceWithMethodWithoutBody.ts @@ -0,0 +1,16 @@ +/// + +////interface ProxyHandler { +//// getPrototypeOf?(target: T): object | null; +////} +////interface ProxyConstructor { +//// new (target: T, handler: ProxyHandler): T; +////} +////declare var Proxy: ProxyConstructor; +////let target = {} +////let proxy = new /**/Proxy(target, { +//// getPrototypeOf() +////}) + +goTo.marker(""); +verify.quickInfoExists();