-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Custom Type Declaration Resolver #29440
Comments
For And we can already read the data/types from a |
I think you are right. But currently |
This feature request looks similar to #3136 |
Yeah, definitely is contained within #3136 at core. But to anyone who finds this: If you can do codegen (because for example the thing you're trying to import types for comes from another build process), it's probably a better choice than trying to inject dynamically generated types into a program. |
This would be very useful for Right now with editor plugins such as |
My mind might be unclear when I was creating this ticket. We mostly use codegen to type other file types, However, recently we import protocol buffers to our project as well. Codegen is not ideal in this case because we need to generate a huge amount of code which has negative impact on performance to us. Therefore I'm thinking if we could have a way to translate other files (especially schemas) to type declaration on-the-fly (or is it more like a custom language service?). |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Search Terms
custom type declaration resolver
Suggestion
Thanks to Webpack, we can import a various of file types by using
loaders
.svg-inline-loader
, for example, reads svg files and outputs a JavaScript module so it can play with JavaScript well.In TypeScript world, handling the type declaration for custom file types could be tricky. For the simple case mentioned-above, we can have ambient declarations like the following:
But for things more dynamic,
wasm
,json
, then this way doesn't work so well because it only provides very static typings.Hence I propose to have a custom declaration resolving mechanism, introducing
declaration resolver
, which is likeloaders
to webpack but emitsd.ts
files. And a way to assign resolvers for different file extensions intsconfig.json
Potentially it could replace
resolveJsonModule
because this one could be delivered as JSON declaration resolver.Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: