-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix crash when trying to import a non-exported type #36619
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
2 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
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/importNonExportedMember2.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests/cases/compiler/b.ts(1,10): error TS2459: Module '"./a"' declares 'Foo' locally, but it is not exported. | ||
|
||
|
||
==== tests/cases/compiler/a.ts (0 errors) ==== | ||
export {} | ||
interface Foo {} | ||
|
||
==== tests/cases/compiler/b.ts (1 errors) ==== | ||
import { Foo } from './a'; | ||
~~~ | ||
!!! error TS2459: Module '"./a"' declares 'Foo' locally, but it is not exported. | ||
!!! related TS2728 tests/cases/compiler/a.ts:2:11: 'Foo' is declared here. | ||
|
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 @@ | ||
//// [tests/cases/compiler/importNonExportedMember2.ts] //// | ||
|
||
//// [a.ts] | ||
export {} | ||
interface Foo {} | ||
|
||
//// [b.ts] | ||
import { Foo } from './a'; | ||
|
||
|
||
//// [a.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
//// [b.js] | ||
"use strict"; | ||
exports.__esModule = true; |
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,9 @@ | ||
=== tests/cases/compiler/a.ts === | ||
export {} | ||
interface Foo {} | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 9)) | ||
|
||
=== tests/cases/compiler/b.ts === | ||
import { Foo } from './a'; | ||
>Foo : Symbol(Foo, Decl(b.ts, 0, 8)) | ||
|
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,8 @@ | ||
=== tests/cases/compiler/a.ts === | ||
export {} | ||
No type information for this code.interface Foo {} | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/b.ts === | ||
import { Foo } from './a'; | ||
>Foo : any | ||
|
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/importNonExportedMember3.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
tests/cases/compiler/b.ts(1,10): error TS2459: Module '"./a"' declares 'Foo' locally, but it is not exported. | ||
|
||
|
||
==== tests/cases/compiler/a.ts (0 errors) ==== | ||
export {} | ||
interface Foo {} | ||
interface Foo {} | ||
namespace Foo {} | ||
|
||
==== tests/cases/compiler/b.ts (1 errors) ==== | ||
import { Foo } from './a'; | ||
~~~ | ||
!!! error TS2459: Module '"./a"' declares 'Foo' locally, but it is not exported. | ||
!!! related TS2728 tests/cases/compiler/a.ts:2:11: 'Foo' is declared here. | ||
!!! related TS6204 tests/cases/compiler/a.ts:3:11: and here. | ||
!!! related TS6204 tests/cases/compiler/a.ts:4:11: and here. | ||
|
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,18 @@ | ||
//// [tests/cases/compiler/importNonExportedMember3.ts] //// | ||
|
||
//// [a.ts] | ||
export {} | ||
interface Foo {} | ||
interface Foo {} | ||
namespace Foo {} | ||
|
||
//// [b.ts] | ||
import { Foo } from './a'; | ||
|
||
|
||
//// [a.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
//// [b.js] | ||
"use strict"; | ||
exports.__esModule = true; |
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/importNonExportedMember3.symbols
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 @@ | ||
=== tests/cases/compiler/a.ts === | ||
export {} | ||
interface Foo {} | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 9), Decl(a.ts, 1, 16), Decl(a.ts, 2, 16)) | ||
|
||
interface Foo {} | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 9), Decl(a.ts, 1, 16), Decl(a.ts, 2, 16)) | ||
|
||
namespace Foo {} | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 9), Decl(a.ts, 1, 16), Decl(a.ts, 2, 16)) | ||
|
||
=== tests/cases/compiler/b.ts === | ||
import { Foo } from './a'; | ||
>Foo : Symbol(Foo, Decl(b.ts, 0, 8)) | ||
|
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,10 @@ | ||
=== tests/cases/compiler/a.ts === | ||
export {} | ||
No type information for this code.interface Foo {} | ||
No type information for this code.interface Foo {} | ||
No type information for this code.namespace Foo {} | ||
No type information for this code. | ||
No type information for this code.=== tests/cases/compiler/b.ts === | ||
import { Foo } from './a'; | ||
>Foo : any | ||
|
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,6 @@ | ||
// @Filename: a.ts | ||
export {} | ||
interface Foo {} | ||
|
||
// @Filename: b.ts | ||
import { Foo } from './a'; |
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,8 @@ | ||
// @Filename: a.ts | ||
export {} | ||
interface Foo {} | ||
interface Foo {} | ||
namespace Foo {} | ||
|
||
// @Filename: b.ts | ||
import { Foo } from './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.
There could be more than one declaration, but exporting any of them will fix the error, so 🤷♂
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.
You could also report an error on all of them which might feel cleaner and work well too.
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.
I'd probably just avoid the
...map
and useforEach
but whatever you'd prefer.