Use non-diagnostics-producing typechecker to get type
This commit is contained in:
parent
97e539339d
commit
bb892d951d
1 changed files with 4 additions and 3 deletions
|
@ -3,7 +3,7 @@ namespace ts {
|
||||||
export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[] {
|
export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[] {
|
||||||
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
||||||
const diags: DiagnosticWithLocation[] = [];
|
const diags: DiagnosticWithLocation[] = [];
|
||||||
const checker = program.getDiagnosticsProducingTypeChecker();
|
const checker = program.getTypeChecker();
|
||||||
|
|
||||||
if (sourceFile.commonJsModuleIndicator &&
|
if (sourceFile.commonJsModuleIndicator &&
|
||||||
(programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) &&
|
(programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) &&
|
||||||
|
@ -115,11 +115,12 @@ namespace ts {
|
||||||
|
|
||||||
function addConvertToAsyncFunctionDiagnostics(node: FunctionLikeDeclaration, checker: TypeChecker, diags: DiagnosticWithLocation[]): void {
|
function addConvertToAsyncFunctionDiagnostics(node: FunctionLikeDeclaration, checker: TypeChecker, diags: DiagnosticWithLocation[]): void {
|
||||||
|
|
||||||
const functionType = node.type ? checker.getTypeFromTypeNode(node.type) : undefined;
|
if (isAsyncFunction(node) || !node.body) {
|
||||||
if (isAsyncFunction(node) || !node.body || !functionType) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const functionType = checker.getTypeAtLocation(node);
|
||||||
|
|
||||||
const callSignatures = checker.getSignaturesOfType(functionType, SignatureKind.Call);
|
const callSignatures = checker.getSignaturesOfType(functionType, SignatureKind.Call);
|
||||||
const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined;
|
const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue