-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Support resolving @typescript/[lib]
in node modules
#45771
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6efc2f1
Support resolving @typescript/x for libs
orta 2ec03f3
Baselines
orta daa99ce
Tightens up the PR
orta e2ca4b5
Fix the build
orta 9943525
Add cache
orta 853ac55
Better naming
orta 2725d3c
Merge branch 'main' of https://github.com/microsoft/TypeScript into l…
orta 77c0e2e
Fixes the lookup path
orta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/baselines/reference/libTypeScriptOverrideSimple.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
tests/cases/compiler/index.ts(6,1): error TS2304: Cannot find name 'window'. | ||
|
||
|
||
==== /node_modules/@typescript/dom/index.d.ts (0 errors) ==== | ||
interface ABC { abc: string } | ||
==== tests/cases/compiler/index.ts (1 errors) ==== | ||
/// <reference lib="dom" /> | ||
const a: ABC = { abc: "Hello" } | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'window'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//// [tests/cases/compiler/libTypeScriptOverrideSimple.ts] //// | ||
|
||
//// [index.d.ts] | ||
interface ABC { abc: string } | ||
//// [index.ts] | ||
/// <reference lib="dom" /> | ||
const a: ABC = { abc: "Hello" } | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage | ||
|
||
//// [index.js] | ||
/// <reference lib="dom" /> | ||
var a = { abc: "Hello" }; | ||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage; |
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/libTypeScriptOverrideSimple.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
=== /node_modules/@typescript/dom/index.d.ts === | ||
interface ABC { abc: string } | ||
>ABC : Symbol(ABC, Decl(index.d.ts, 0, 0)) | ||
>abc : Symbol(ABC.abc, Decl(index.d.ts, 0, 15)) | ||
|
||
=== tests/cases/compiler/index.ts === | ||
/// <reference lib="dom" /> | ||
const a: ABC = { abc: "Hello" } | ||
>a : Symbol(a, Decl(index.ts, 1, 5)) | ||
>ABC : Symbol(ABC, Decl(index.d.ts, 0, 0)) | ||
>abc : Symbol(abc, Decl(index.ts, 1, 16)) | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/libTypeScriptOverrideSimple.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
=== /node_modules/@typescript/dom/index.d.ts === | ||
interface ABC { abc: string } | ||
>abc : string | ||
|
||
=== tests/cases/compiler/index.ts === | ||
/// <reference lib="dom" /> | ||
const a: ABC = { abc: "Hello" } | ||
>a : ABC | ||
>{ abc: "Hello" } : { abc: string; } | ||
>abc : string | ||
>"Hello" : "Hello" | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage | ||
>window.localStorage : any | ||
>window : any | ||
>localStorage : any | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/libTypeScriptSubfileResolving.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
tests/cases/compiler/index.ts(6,1): error TS2304: Cannot find name 'window'. | ||
|
||
|
||
==== /node_modules/@typescript/dom/index.d.ts (0 errors) ==== | ||
// NOOP | ||
==== /node_modules/@typescript/dom/iterable.d.ts (0 errors) ==== | ||
interface DOMIterable { abc: string } | ||
==== tests/cases/compiler/index.ts (1 errors) ==== | ||
/// <reference lib="dom.iterable" /> | ||
const a: DOMIterable = { abc: "Hello" } | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage | ||
~~~~~~ | ||
!!! error TS2304: Cannot find name 'window'. |
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/libTypeScriptSubfileResolving.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//// [tests/cases/compiler/libTypeScriptSubfileResolving.ts] //// | ||
|
||
//// [index.d.ts] | ||
// NOOP | ||
//// [iterable.d.ts] | ||
interface DOMIterable { abc: string } | ||
//// [index.ts] | ||
/// <reference lib="dom.iterable" /> | ||
const a: DOMIterable = { abc: "Hello" } | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage | ||
|
||
//// [index.js] | ||
/// <reference lib="dom.iterable" /> | ||
var a = { abc: "Hello" }; | ||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage; |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/libTypeScriptSubfileResolving.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
=== /node_modules/@typescript/dom/index.d.ts === | ||
// NOOP | ||
No type information for this code.=== /node_modules/@typescript/dom/iterable.d.ts === | ||
interface DOMIterable { abc: string } | ||
>DOMIterable : Symbol(DOMIterable, Decl(iterable.d.ts, 0, 0)) | ||
>abc : Symbol(DOMIterable.abc, Decl(iterable.d.ts, 0, 23)) | ||
|
||
=== tests/cases/compiler/index.ts === | ||
/// <reference lib="dom.iterable" /> | ||
const a: DOMIterable = { abc: "Hello" } | ||
>a : Symbol(a, Decl(index.ts, 1, 5)) | ||
>DOMIterable : Symbol(DOMIterable, Decl(iterable.d.ts, 0, 0)) | ||
>abc : Symbol(abc, Decl(index.ts, 1, 24)) | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/libTypeScriptSubfileResolving.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
=== /node_modules/@typescript/dom/index.d.ts === | ||
// NOOP | ||
No type information for this code.=== /node_modules/@typescript/dom/iterable.d.ts === | ||
interface DOMIterable { abc: string } | ||
>abc : string | ||
|
||
=== tests/cases/compiler/index.ts === | ||
/// <reference lib="dom.iterable" /> | ||
const a: DOMIterable = { abc: "Hello" } | ||
>a : DOMIterable | ||
>{ abc: "Hello" } : { abc: string; } | ||
>abc : string | ||
>"Hello" : "Hello" | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage | ||
>window.localStorage : any | ||
>window : any | ||
>localStorage : any | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @Filename: /node_modules/@typescript/dom/index.d.ts | ||
interface ABC { abc: string } | ||
// @Filename: index.ts | ||
/// <reference lib="dom" /> | ||
const a: ABC = { abc: "Hello" } | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @Filename: /node_modules/@typescript/dom/index.d.ts | ||
// NOOP | ||
// @Filename: /node_modules/@typescript/dom/iterable.d.ts | ||
interface DOMIterable { abc: string } | ||
// @Filename: index.ts | ||
/// <reference lib="dom.iterable" /> | ||
const a: DOMIterable = { abc: "Hello" } | ||
|
||
// This should fail because libdom has been replaced | ||
// by the module above ^ | ||
window.localStorage |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This always ignores
currentDirectory
because the latter argument is absolute.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing this didn’t break tests only because all the tests are rooted at
/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice spot!