Skip to content

Adds support for overwriting lib references via the TSConfig - #45518

Closed
orta wants to merge 1 commit into
microsoft:mainfrom
orta:libOverrides
Closed

Adds support for overwriting lib references via the TSConfig #45518
orta wants to merge 1 commit into
microsoft:mainfrom
orta:libOverrides

Conversation

@orta

@ortaorta commented Aug 19, 2021

Copy link
Copy Markdown
Contributor

Fixes#44795

This PR changes the lib file resolving based on whether you have included an override in your tsconfig.json, so for example:

{
"compilerOptions": {
"target": "es2015",
"lib": ["es2015", { replace: "dom", with: "@types/web" }]
}
}

Would never access lib.dom.d.ts if it were imported via a /// <reference lib="dom" /> - it would redirect to @types/web resolved relative to the tsconfig.json which is how it would be referred to by DT modules and libraries.


PR TODO

  • Resolve the with to a real file path during tsconfig creation, so that it can be used later before the checker starts up (and by which point we've lost the reference to the tsconfig filepath)
  • Add some error handling
  • Cleanup all the 'do not ship with theses
  • Add a getLib helper which returns string[]
  • Test with symlinks (e.g. replace dom where the file is a symlink, and where the dir where the file lives is a symlink)

@orta

orta commented Sep 8, 2021

Copy link
Copy Markdown
ContributorAuthor

This is likely to not ship in favor of #45771

@microsoftmicrosoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support having '@types/web' as overriding 'dom' in TypeScript's lib resolver

2 participants

@orta@typescript-bot