-
Notifications
You must be signed in to change notification settings - Fork 430
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
Enable importing types via module #1874
Conversation
After some discussion on discord, we decided not to take this right now. @kraenhansen is planning to publish the module-wrapped code as separate package instead. My reasoning is: The environment problem isn't restricted to the DOM types, although that's where the problem is worst. However, we need to consider the whole problem and have a whole solution ready -- which needs design work and likely needs compiler work. Unfortunately I don't think it got a lot of votes on the team for being the next thing we go work on last time we discussed that. For this specific solution: I don't love the idea of shipping module copies of the global originals, since it doubles the size. It also requires the user to be using modules. Given the intended usage -- directly imports and only importing types -- I think the best path forward is to publish the module-wrapped types as non- |
@saschanaz I wonder if you'd be open to donate the types-web package for this purpose? ☝️ |
Per @sandersn's post it seems the decision is maybe let people to experiment with their own packages and then later consider merging it. Having the name |
This fixes #1207 by:
CompilerBehavior
:exportTypes
emits "export" statements before anyinterface
,type
and aexport type { Foo }
for namespaces.omitDeclares
prevents emitting ofdeclare var
anddeclare function
statements which pollute the global namespace../module
) with the two new options enabled.I have also:
ts5.5
which were currently not being tested).Merging this PR will allow users to import DOM types like this:
Ideally users would import directly (
from "@types/web/module"
), but this results in: