cevek / ttypescript

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

`ttsc` is not working on TS 4.9 #134

Closed samchon closed 1 year ago

samchon commented 1 year ago

ts-node -C ttypescript works, but ttsc is not working.

code transformation does not working.

Smrtnyk commented 1 year ago

It looks related to https://github.com/microsoft/TypeScript/issues/51542 probably not an issue of ttypescript

DanielRosenwasser commented 1 year ago

4.9.4 is now out FWIW

samchon commented 1 year ago

TS has been updated to 4.9.4, but transformation is not working yet.

How about you @nonara ?

samchon commented 1 year ago

@DanielRosenwasser May I ask you one thing?

Looking at code of this ttypescript, it transforms TS source code by replacing ts.createProgram function. But after TS 4.9 patch, the transformed.createTransform function never be called. Is there any criticial change on TS not to call the createProgram function or overwrite the createProgram function variable when compiling?

https://github.com/cevek/ttypescript/blob/a81ff1744aa2e505273adbc0ef7d788237165720/packages/ttypescript/src/patchCreateProgram.ts#L32-L113

nonara commented 1 year ago

@samchon I'll take a look tomorrow and work it out.

samchon commented 1 year ago

@cevek I just analyzed what makes ttypescript broken for a while. Hope my analysis to be helpful.


I'd tried hard coding special editing on tsc.js of TS and succeeded to transforming by modifing performCompilation function to be exported function. However, the performCompilation function is not exported member, but an internal function of executeCommandLine.ts file.

Therefore, to fix this bug occured after TS 4.9 update, ttypescript should update not only createProgram file, but also executeCommandLine function too.


@DanielRosenwasser Is it possible to change the executeCommandLine function provides an additional and optional prarameter that creating the Program class instance? Or can you re-patch the TS 4.9 (maybe 4.9.5) that only wrapping ts.createProgram can be working again? I think it would be really helpful for @cevek, developer of this ttypescript project and the others using this ttypescript library.

nonara commented 1 year ago

@samchon Libraries like tts and ts-patch augment the TypeScript libraries. It isn't the TS team's responsibility to modify the compiler to support our tools. The functions we modify are internal and not a part of public API, so it's on us to keep up with changes.

If this is an issue, I'll have ts-patch working later today. Unfortunately, I don't have access to modify this library, so you'll have to wait on @cevek to follow suit.

I will update in this thread when I've investigated the issue.

nonara commented 1 year ago

ts 4.9.4 support is added in ts-patch v2.1.0

forinda commented 1 year ago

ts 4.9.4 support is added in ts-patch v2.1.0

ts 4.9.4 support is added in ts-patch v2.1.0

So downgrading typescript from ^5.x.x to ^4.x.x works 🎉

abbaty48 commented 1 year ago

No solution yet for ts5, downgrading to 4 works

nonara commented 1 year ago

Latest ts-patch rc (beta) supports ts v5, and I added some functionality so you don't have to do anything major to migrate from ttypescript. Just install and use tspc instead of ttsc

Here's more detail: