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:exportTypesemits "export" statements before anyinterface,typeand aexport type { Foo }for namespaces.omitDeclaresprevents emitting ofdeclare varanddeclare functionstatements which pollute the global namespace../module) with the two new options enabled.I have also:
ts5.5which 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: