-
Notifications
You must be signed in to change notification settings - Fork 457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment: Try out TypeScript Program in compiler #1146
Comments
Hey! I looked a bit into
Maybe we could learn e. g. from Angular/webpack, how it compiles incrementally using the TS language service with TS Program and TypeChecker (this is the place where Angular's webpack plugin creates the program etc). Obvoiusly tansformers without TypeChecker functionality are way less powerful and restricted. The language service itself gets created in As an ugly workaround you could create your own program instance for the transformer using I'm interested in your findings as well, cheers! |
@wtho I'm already doing this ugly workaround in my PoC project And I've found it extremely slow (adding roughle 1.5seconds per file). So if such PR would be accepted I can prepare modifications providing the language service for transformers. |
I am not a But I personally would be interested in performance results of an implementation with a single I am not in the position to suggest a PR, but I think it is valuable for |
According to @huafu , he said once about transformer should be only initialized once for all tests. Does it mean about Program instance ? |
No, it is not really related to the transformer lifecycle. Basically, there are two ways to compile TS code to JS calling the tsc compiler programmatically:
huafu once stated (see above) that See https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API for further information. |
Not dive into createProgram yet but creating instance once for all tests already sounds logical. I’d go for it. How do we approach that solution ? |
This might be too costly, as huafu stated before, but we should give it a shot. There is not much literature about the TS compiler API. It is probably best to have a look at how other compilers (e. g. Angular-cli, Vue-cli, webpack-ts-loader, webpack-awesome-typescript-loader) do this and learn from them. I looked a bit into Angular Compilation, but it is quite complicated, it might be better to have a look at the others (and check if they use |
Thanks for the info 🙏, I’m curious how the examples do with that pattern Updated: I have an idea for this experiment.
I'd say the main changes will be:
What do you think about the approach @wtho @mtebenev ? |
Yeah! Thanks so much! |
Issue :
Hi guys! Is there a way to get access to the TS Program/TypeChecker instance from inside of a custom AST transformer?
There was a similar question #303 At that time it wasn't possible but now ts-jest uses TS language service I guess it is possible? Would passing the languageService to ConfigSet introduce some issues?
The text was updated successfully, but these errors were encountered: