Closed
Description
Expected Behaviour
This should not throw an error:
export function transformer(program: ts.Program) {
return (context: ts.TransformationContext) => (file: ts.SourceFile) => {
if (program.getSourceFile(file.fileName).getText() !== file.getText()) {
throw new Error();
}
};
}
Actual Behaviour
The files in the program
instance passed in becomes stale when you have a watch running, and program.getSourceFile()
will return the file as it looked when the watch started.
I was the one who added the program
argument to getCustomTransformers
so I'm the one to blame here. 😄 To avoid a breaking change I think we could change it from:
(program: Program) => { before?: TransformerFactory<SourceFile>[]; after?: TransformerFactory<SourceFile>[]; }
to:
(program: Program, getProgram: () => Program) => { before?: TransformerFactory<SourceFile>[]; after?: TransformerFactory<SourceFile>[]; }
And in a new major remove the passed in program and just pass a function that gets the latest program instance.
Metadata
Metadata
Assignees
Labels
No labels