-
Notifications
You must be signed in to change notification settings - Fork 723
Consistently error on full circle of circular import aliases #1904
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
23 changes: 23 additions & 0 deletions
23
testdata/baselines/reference/submodule/compiler/circularModuleImports.errors.txt.diff
This file contains hidden or 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,23 @@ | ||
| --- old.circularModuleImports.errors.txt | ||
| +++ new.circularModuleImports.errors.txt | ||
| @@= skipped -0, +0 lines =@@ | ||
| circularModuleImports.ts(5,5): error TS2303: Circular definition of import alias 'A'. | ||
| - | ||
| - | ||
| -==== circularModuleImports.ts (1 errors) ==== | ||
| +circularModuleImports.ts(7,5): error TS2303: Circular definition of import alias 'B'. | ||
| + | ||
| + | ||
| +==== circularModuleImports.ts (2 errors) ==== | ||
| module M | ||
|
|
||
| { | ||
| @@= skipped -10, +11 lines =@@ | ||
| !!! error TS2303: Circular definition of import alias 'A'. | ||
|
|
||
| import B = A; | ||
| + ~~~~~~~~~~~~~ | ||
| +!!! error TS2303: Circular definition of import alias 'B'. | ||
|
|
||
| } | ||
|
|
7 changes: 5 additions & 2 deletions
7
testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| declarationEmitUnknownImport.ts(1,1): error TS2303: Circular definition of import alias 'Foo'. | ||
| declarationEmitUnknownImport.ts(1,14): error TS2304: Cannot find name 'SomeNonExistingName'. | ||
| declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. | ||
| declarationEmitUnknownImport.ts(2,9): error TS2303: Circular definition of import alias 'Foo'. | ||
|
|
||
|
|
||
| ==== declarationEmitUnknownImport.ts (3 errors) ==== | ||
| ==== declarationEmitUnknownImport.ts (4 errors) ==== | ||
| import Foo = SomeNonExistingName | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2303: Circular definition of import alias 'Foo'. | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2304: Cannot find name 'SomeNonExistingName'. | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2503: Cannot find namespace 'SomeNonExistingName'. | ||
| export {Foo} | ||
| export {Foo} | ||
| ~~~ | ||
| !!! error TS2303: Circular definition of import alias 'Foo'. |
22 changes: 22 additions & 0 deletions
22
testdata/baselines/reference/submodule/compiler/declarationEmitUnknownImport.errors.txt.diff
This file contains hidden or 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,22 @@ | ||
| --- old.declarationEmitUnknownImport.errors.txt | ||
| +++ new.declarationEmitUnknownImport.errors.txt | ||
| @@= skipped -0, +0 lines =@@ | ||
| declarationEmitUnknownImport.ts(1,1): error TS2303: Circular definition of import alias 'Foo'. | ||
| declarationEmitUnknownImport.ts(1,14): error TS2304: Cannot find name 'SomeNonExistingName'. | ||
| declarationEmitUnknownImport.ts(1,14): error TS2503: Cannot find namespace 'SomeNonExistingName'. | ||
| - | ||
| - | ||
| -==== declarationEmitUnknownImport.ts (3 errors) ==== | ||
| +declarationEmitUnknownImport.ts(2,9): error TS2303: Circular definition of import alias 'Foo'. | ||
| + | ||
| + | ||
| +==== declarationEmitUnknownImport.ts (4 errors) ==== | ||
| import Foo = SomeNonExistingName | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2303: Circular definition of import alias 'Foo'. | ||
| @@= skipped -11, +12 lines =@@ | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2503: Cannot find namespace 'SomeNonExistingName'. | ||
| export {Foo} | ||
| + ~~~ | ||
| +!!! error TS2303: Circular definition of import alias 'Foo'. |
This file contains hidden or 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
22 changes: 22 additions & 0 deletions
22
...data/baselines/reference/submodule/compiler/declarationEmitUnknownImport2.errors.txt.diff
This file contains hidden or 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,22 @@ | ||
| --- old.declarationEmitUnknownImport2.errors.txt | ||
| +++ new.declarationEmitUnknownImport2.errors.txt | ||
| @@= skipped -2, +2 lines =@@ | ||
| declarationEmitUnknownImport2.ts(1,12): error TS2304: Cannot find name 'From'. | ||
| declarationEmitUnknownImport2.ts(1,12): error TS2503: Cannot find namespace 'From'. | ||
| declarationEmitUnknownImport2.ts(1,17): error TS1005: ';' expected. | ||
| - | ||
| - | ||
| -==== declarationEmitUnknownImport2.ts (5 errors) ==== | ||
| +declarationEmitUnknownImport2.ts(2,1): error TS2303: Circular definition of import alias 'Foo'. | ||
| + | ||
| + | ||
| +==== declarationEmitUnknownImport2.ts (6 errors) ==== | ||
| import Foo From './Foo'; // Syntax error | ||
| ~~~~~~~~~~~~~~~ | ||
| !!! error TS2303: Circular definition of import alias 'Foo'. | ||
| @@= skipped -15, +16 lines =@@ | ||
| ~~~~~~~ | ||
| !!! error TS1005: ';' expected. | ||
| export default Foo | ||
| + ~~~~~~~~~~~~~~~~~~ | ||
| +!!! error TS2303: Circular definition of import alias 'Foo'. |
5 changes: 4 additions & 1 deletion
5
testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
testdata/baselines/reference/submodule/compiler/exportAsNamespaceConflict.errors.txt.diff
This file contains hidden or 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 @@ | ||
| --- old.exportAsNamespaceConflict.errors.txt | ||
| +++ new.exportAsNamespaceConflict.errors.txt | ||
| @@= skipped -0, +0 lines =@@ | ||
| +/a.d.ts(2,1): error TS2303: Circular definition of import alias 'N'. | ||
| /a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'. | ||
|
|
||
|
|
||
| -==== /a.d.ts (1 errors) ==== | ||
| +==== /a.d.ts (2 errors) ==== | ||
| declare global { namespace N {} } | ||
| export = N; | ||
| + ~~~~~~~~~~~ | ||
| +!!! error TS2303: Circular definition of import alias 'N'. | ||
| export as namespace N; | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2303: Circular definition of import alias 'N'. |
5 changes: 4 additions & 1 deletion
5
testdata/baselines/reference/submodule/conformance/circular1.errors.txt
This file contains hidden or 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
15 changes: 15 additions & 0 deletions
15
testdata/baselines/reference/submodule/conformance/circular1.errors.txt.diff
This file contains hidden or 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 @@ | ||
| --- old.circular1.errors.txt | ||
| +++ new.circular1.errors.txt | ||
| @@= skipped -0, +0 lines =@@ | ||
| +/a.ts(1,15): error TS2303: Circular definition of import alias 'A'. | ||
| /b.ts(1,15): error TS2303: Circular definition of import alias 'A'. | ||
|
|
||
|
|
||
| -==== /a.ts (0 errors) ==== | ||
| +==== /a.ts (1 errors) ==== | ||
| export type { A } from './b'; | ||
| + ~ | ||
| +!!! error TS2303: Circular definition of import alias 'A'. | ||
|
|
||
| ==== /b.ts (1 errors) ==== | ||
| export type { A } from './a'; |
13 changes: 11 additions & 2 deletions
13
testdata/baselines/reference/submodule/conformance/circular3.errors.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,13 +1,22 @@ | ||
| /a.ts(1,15): error TS2303: Circular definition of import alias 'A'. | ||
| /a.ts(2,15): error TS2303: Circular definition of import alias 'B'. | ||
| /b.ts(1,15): error TS2303: Circular definition of import alias 'B'. | ||
| /b.ts(2,15): error TS2303: Circular definition of import alias 'A'. | ||
|
|
||
|
|
||
| ==== /a.ts (0 errors) ==== | ||
| ==== /a.ts (2 errors) ==== | ||
| import type { A } from './b'; | ||
| ~ | ||
| !!! error TS2303: Circular definition of import alias 'A'. | ||
| export type { A as B }; | ||
| ~~~~~~ | ||
| !!! error TS2303: Circular definition of import alias 'B'. | ||
|
|
||
| ==== /b.ts (1 errors) ==== | ||
| ==== /b.ts (2 errors) ==== | ||
| import type { B } from './a'; | ||
| ~ | ||
| !!! error TS2303: Circular definition of import alias 'B'. | ||
| export type { B as A }; | ||
| ~~~~~~ | ||
| !!! error TS2303: Circular definition of import alias 'A'. | ||
|
|
29 changes: 29 additions & 0 deletions
29
testdata/baselines/reference/submodule/conformance/circular3.errors.txt.diff
This file contains hidden or 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,29 @@ | ||
| --- old.circular3.errors.txt | ||
| +++ new.circular3.errors.txt | ||
| @@= skipped -0, +0 lines =@@ | ||
| +/a.ts(1,15): error TS2303: Circular definition of import alias 'A'. | ||
| +/a.ts(2,15): error TS2303: Circular definition of import alias 'B'. | ||
| /b.ts(1,15): error TS2303: Circular definition of import alias 'B'. | ||
| - | ||
| - | ||
| -==== /a.ts (0 errors) ==== | ||
| +/b.ts(2,15): error TS2303: Circular definition of import alias 'A'. | ||
| + | ||
| + | ||
| +==== /a.ts (2 errors) ==== | ||
| import type { A } from './b'; | ||
| + ~ | ||
| +!!! error TS2303: Circular definition of import alias 'A'. | ||
| export type { A as B }; | ||
| + ~~~~~~ | ||
| +!!! error TS2303: Circular definition of import alias 'B'. | ||
|
|
||
| -==== /b.ts (1 errors) ==== | ||
| +==== /b.ts (2 errors) ==== | ||
| import type { B } from './a'; | ||
| ~ | ||
| !!! error TS2303: Circular definition of import alias 'B'. | ||
| export type { B as A }; | ||
| + ~~~~~~ | ||
| +!!! error TS2303: Circular definition of import alias 'A'. | ||
|
|
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.
Hopefully this extra
findisn't too expensive, given how often we resolve aliases.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.
tryResolveAliasis only called when generating spelling correction suggestions, so not an issue at all. And anyway, every call topushTypeResolutionhas a call to thatfindmethod with no issues.