cevek / ttypescript

Over TypeScript tool to use custom transformers in the tsconfig.json
1.53k stars 56 forks source link

ttypescript does not patch createWatchProgram #110

Open mrmeku opened 3 years ago

mrmeku commented 3 years ago

Currently ttypescript patches createProgram but does not patch createWatchProgram or createIncrementalProgram. As a result, transformations do not occur when calling those two APIs which is unexpected

nonara commented 3 years ago

Working on this in ts-patch now - https://github.com/nonara/ts-patch/issues/35

nonara commented 3 years ago

I looked into this a bit. I'm not sure I see how this wouldn't work.

But, if it isn't working, I believe I found the solution.

For createIncrementalProgram, look at the signature and you will see that it takes a createProgram function as an argument. Pass ts.createProgram to it (where ts is your patched typescript instance) and it should work.

For createWatchProgram you also need to pass it a WatchCompilerHost, which is created using createWatchCompilerHost. In that case, check the signature for createWatchCompilerHost and you will see a parameter which takes a createProgram function. Follow the same procedure for that, and it should work.

If it isn't working, create a reproduction using ts-patch, and I'll have a look!