-
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
Proposal: Lookup lib
files from individual node packages before falling back to builtin libs
#45685
Comments
Yeah, confirmed that this works and to be honest - it feels like the best answer to me. I believe this is probably the most reliable setup for it across all package managers: {
"dependencies": {
"@typescript/libdom": "npm:@types/web"
}
} |
TIL that |
There's also |
One thing I'm trying to think about is what this could look like with respect to #43972 I think my current plan is to separate out Do you think then that would resolve to |
I'm thinking the later. Separate packages for each referencable lib we add so you can override/fallback each one individually. |
Hrm, is both a plausible answer also? Today If they were one per packages you'd need to do:
Which would probably be a bit of an overkill, but if we supported internal routing at the
turning into:
|
Implemented in #45771 |
Glad to see this feature implemented! May we have an example please of how to override types from I'd like to ship a types package that makes |
⭐ Suggestion
For any given lib option
{lib}
, egdom
ores2019
, we should look up a module@typescript/lib{lib}
(eg,@typescript/libdom
or@typescript/libes2019
) for the library file before falling back to loading the lib file bundled with the compiler. This will allow users to bring their own lib copies by overriding or redirecting this package to their own versions of it, and offload version conflict checking to package managers.📃 Motivating Example
In #44795 we express a desire to override the builtin
dom
with another version of thedom
lib. This would allow us to do so. Specifically, if we load@typescript/libdom
for thedom
.d.ts
files, you could make yourpackage.json
look like this:we'd then find the
@types/web
declaration files (linked) in the@typescript/libdom
folder, and load them as the canonicaldom
lib. The package manager can then take care of version conflicts between customdom
versions (obviously only one top-level@typescript/libdom
folder can be installed!) and handle redirects for us.cc @orta @andrewbranch
The text was updated successfully, but these errors were encountered: