Skip to content

Commit

Permalink
Improve the performance of isolatedDeclarations quickfix
Browse files Browse the repository at this point in the history
It turns out that `typeChecker.getEmitResolver()` can be expensive,
so avoid calling it unless necessary.

Hopefully this fixes the performance issue (bullet microsoft#1) of
microsoft#58426
  • Loading branch information
blickly committed May 30, 2024
1 parent 59e6620 commit 5f53116
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/services/codefixes/fixMissingTypeAnnotationOnExports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ function withContext<T>(
const sourceFile: SourceFile = context.sourceFile;
const program = context.program;
const typeChecker: TypeChecker = program.getTypeChecker();
const emitResolver = typeChecker.getEmitResolver();
const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
const importAdder = createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
const fixedNodes = new Set<Node>();
Expand Down Expand Up @@ -887,7 +886,7 @@ function withContext<T>(
type = widenedType;
}

if (isParameter(node) && emitResolver.requiresAddingImplicitUndefined(node)) {
if (isParameter(node) && typeChecker.getEmitResolver().requiresAddingImplicitUndefined(node)) {
type = typeChecker.getUnionType([typeChecker.getUndefinedType(), type], UnionReduction.None);
}
const flags = (
Expand Down

0 comments on commit 5f53116

Please sign in to comment.