Skip to content

Commit

Permalink
fix(type-compiler): mark the right SourceFile object as processed
Browse files Browse the repository at this point in the history
Previously the original ts.SourceFile was marked as processed, which is incorrect. The returning new object should be marked instead.
  • Loading branch information
marcj committed Feb 28, 2024
1 parent d2b1c26 commit 38cfdf0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/type-compiler/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import type {
TypeReferenceNode,
UnionTypeNode,
} from 'typescript';

import ts from 'typescript';

import {
Expand Down Expand Up @@ -614,7 +613,6 @@ export class ReflectionTransformer implements CustomTransformer {
if (sourceFile.scriptKind !== ScriptKind.TS && sourceFile.scriptKind !== ScriptKind.TSX) return sourceFile;

if ((sourceFile as any).deepkitTransformed) return sourceFile;
(sourceFile as any).deepkitTransformed = true;
this.embedAssignType = false;
this.addImports = [];

Expand Down Expand Up @@ -1041,6 +1039,7 @@ export class ReflectionTransformer implements CustomTransformer {
// console.log(createPrinter().printNode(EmitHint.SourceFile, this.sourceFile, this.sourceFile));
const took = Date.now() - start;
debug(`Transform file with reflection=${reflection.mode} took ${took}ms (${this.getModuleType()}) ${sourceFile.fileName} via config ${reflection.tsConfigPath || 'none'}.`);
(this.sourceFile as any).deepkitTransformed = true;
return this.sourceFile;
}

Expand Down Expand Up @@ -2713,7 +2712,6 @@ export class DeclarationTransformer extends ReflectionTransformer {

transformSourceFile(sourceFile: SourceFile): SourceFile {
if ((sourceFile as any).deepkitDeclarationTransformed) return sourceFile;
(sourceFile as any).deepkitDeclarationTransformed = true;

this.sourceFile = sourceFile;
this.addExports = [];
Expand Down Expand Up @@ -2763,6 +2761,8 @@ export class DeclarationTransformer extends ReflectionTransformer {
this.sourceFile = this.f.updateSourceFile(this.sourceFile, [...this.sourceFile.statements, ...exports]);
}

(this.sourceFile as any).deepkitDeclarationTransformed = true;

return this.sourceFile;
}
}
Expand Down

0 comments on commit 38cfdf0

Please sign in to comment.