-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
⭐ Suggestion
For any given lib option {lib}, eg dom or es2019, 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 the dom lib. This would allow us to do so. Specifically, if we load @typescript/libdom for the dom .d.ts files, you could make your package.json look like this:
{
"dependencies": {
"@types/web": "*",
"@typescript/libdom": "node_modules/@types/web"
}
}we'd then find the @types/web declaration files (linked) in the @typescript/libdom folder, and load them as the canonical dom lib. The package manager can then take care of version conflicts between custom dom versions (obviously only one top-level @typescript/libdom folder can be installed!) and handle redirects for us.