-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
Introduce programTransformers option #879
Introduce programTransformers option #879
Conversation
e.g. it will allow for a transformer to have an access to type checker
@blakeembrey sorry for bugging, what are your thoughts on this? |
@saitonakamura This looks great, but how about we just make it a union signature of |
Thanks @blakeembrey for suggestion!
@blakeembrey yeah, totally, I don't know why I haven't thought about it in the first place, too much C# I guess 😃 . Thank you, I've done it and it helped to simplify the code! |
Thanks for merging and refactoring it! |
Here's the story, I have a transformer that can generate a runtime validation for json based on a generic type parameter. For that I need to have an access to a type checker, but vanilla transformers can't do that. I came across a solution in
ts-loader
: instead of passing an object literal, you pass a function that accepts aProgram
and should return that object with transformers. So I implemented the same api ints-node
considering the backwards compatibility (it's a brand new separate option). While implementing I came across chicken-egg problem causeLanguageServiceHost
accepts transformers function, but you can only get an access to program once you create aLanguageService
itself, so i'm kinda using the variable that will be initialized later. It's working, though it can be fragile with different typescript versions.I'm also not sure about the name of the option
programTransformers
. It doens't sound like a perfect one, but i'm yet to find out the better alternative. @blakeembrey maybe you have some ideas?Fixes #792