You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without the feature, anything can be used instead of exportedFunction, but with the feature it would be possible to restrict the name and type the result:
That's a fairly simple example, but it becomes more interesting when passing functions that would receive those exported objects as their parameters, etc.
π» Use Cases
Usage:
plugin mechanisms
lazy-loading features
build-time DSLs
Short-comings with the current approach:
nothing but import() can be used while keeping type information
Short-comings with the proposed approach:
tooling may sometimes need to be adapted to "detect" such new import constructs
Workarounds:
not many are available apart from importing the type/re-declaring separately
The text was updated successfully, but these errors were encountered:
Hm true, and a little bit #31090 as well
I suppose it's not worth keeping this one opened then, and instead I can go thumb-up the other ones or something π
edit: and #42046 aka I need to get better at searching for existing issues
Suggestion
Expand the (very nice) ability to infer the type of an
import()
call expression so that such imports can be wrapped.π Search Terms
typeof import
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Make it possible to expose the type of what a module exports:
π Motivating Example
Library code that allows plugins, lazy-loading, etc. needs the user code to perform the import call itself in order to get typing information.
Without the feature, anything can be used instead of
exportedFunction
, but with the feature it would be possible to restrict the name and type the result:That's a fairly simple example, but it becomes more interesting when passing functions that would receive those exported objects as their parameters, etc.
π» Use Cases
Usage:
Short-comings with the current approach:
Short-comings with the proposed approach:
Workarounds:
The text was updated successfully, but these errors were encountered: