Basically what I am trying is to make some ts file (global.ts) act like a "header file":
// global.ts
function mylog(msg: any) {
console.log(String(msg))
}
// a.ts
mylog("a")
// b.ts
mylog("b")
gets
// a.js
function mylog(msg) {
console.log(String(msg))
}
mylog("a")
// b.js
function mylog(msg) {
console.log(String(msg))
}
mylog("b")
I am creating a watch compiler using createWatchCompilerHost and createWatchProgram, injecting transformers by "intercepting createProgram and overriding its emit method" hacking:
TypeScript custom transformers with ts.createWatchProgram
There are 3 key requirements:
- No emitting for the "header file". (I know d.ts, but the "header file" contains implementations.)
- (On the first run) Run transformer first on the "header file" (to grab AST), then other files.
- Recompile all files when the "header file" changes.
Current progress:
- Don't know
- Don't know
- Recompilation only triggered by symbolic changes of the "header file"; implementation changes alone won't trigger.
Anyone give some help?