Skip to content

Commit bb892d9

Browse files
author
Benjamin Lichtman
committed
Use non-diagnostics-producing typechecker to get type
1 parent 97e5393 commit bb892d9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/services/suggestionDiagnostics.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace ts {
33
export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[] {
44
program.getSemanticDiagnostics(sourceFile, cancellationToken);
55
const diags: DiagnosticWithLocation[] = [];
6-
const checker = program.getDiagnosticsProducingTypeChecker();
6+
const checker = program.getTypeChecker();
77

88
if (sourceFile.commonJsModuleIndicator &&
99
(programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) &&
@@ -115,11 +115,12 @@ namespace ts {
115115

116116
function addConvertToAsyncFunctionDiagnostics(node: FunctionLikeDeclaration, checker: TypeChecker, diags: DiagnosticWithLocation[]): void {
117117

118-
const functionType = node.type ? checker.getTypeFromTypeNode(node.type) : undefined;
119-
if (isAsyncFunction(node) || !node.body || !functionType) {
118+
if (isAsyncFunction(node) || !node.body) {
120119
return;
121120
}
122121

122+
const functionType = checker.getTypeAtLocation(node);
123+
123124
const callSignatures = checker.getSignaturesOfType(functionType, SignatureKind.Call);
124125
const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined;
125126

0 commit comments

Comments
 (0)