You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
It's worth noting that with the proposed changes in #1350 it would still give a stale program for configurations using transpileOnly-flag. Not really sure how to combat that though.
Edit: Before #1350, the program didn't contain any files, so one could argue that this is better, but ideally, I would like to find a solution to this.
Expected Behaviour
This should not throw an error:
Actual Behaviour
The files in the
program
instance passed in becomes stale when you have a watch running, andprogram.getSourceFile()
will return the file as it looked when the watch started.I was the one who added the
program
argument togetCustomTransformers
so I'm the one to blame here. 😄 To avoid a breaking change I think we could change it from:to:
And in a new major remove the passed in program and just pass a function that gets the latest program instance.
The text was updated successfully, but these errors were encountered: