-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Make the implicitly exported rule consistent between checker and binder #54659
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
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
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/namespaceNotMergedWithFunctionDefaultExport.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,19 @@ | ||
replace-in-file/types/index.d.ts(4,19): error TS2395: Individual declarations in merged declaration 'replaceInFile' must be all exported or all local. | ||
replace-in-file/types/index.d.ts(7,13): error TS2395: Individual declarations in merged declaration 'replaceInFile' must be all exported or all local. | ||
|
||
|
||
==== replace-in-file/types/index.d.ts (2 errors) ==== | ||
// repro from https://github.com/microsoft/TypeScript/issues/54342 | ||
|
||
declare module 'replace-in-file' { | ||
export function replaceInFile(config: unknown): Promise<unknown[]>; | ||
~~~~~~~~~~~~~ | ||
!!! error TS2395: Individual declarations in merged declaration 'replaceInFile' must be all exported or all local. | ||
export default replaceInFile; | ||
|
||
namespace replaceInFile { | ||
~~~~~~~~~~~~~ | ||
!!! error TS2395: Individual declarations in merged declaration 'replaceInFile' must be all exported or all local. | ||
export function sync(config: unknown): unknown[]; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/namespaceNotMergedWithFunctionDefaultExport.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,24 @@ | ||
//// [tests/cases/compiler/namespaceNotMergedWithFunctionDefaultExport.ts] //// | ||
|
||
=== replace-in-file/types/index.d.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54342 | ||
|
||
declare module 'replace-in-file' { | ||
>'replace-in-file' : Symbol("replace-in-file", Decl(index.d.ts, 0, 0)) | ||
|
||
export function replaceInFile(config: unknown): Promise<unknown[]>; | ||
>replaceInFile : Symbol(replaceInFile, Decl(index.d.ts, 2, 34)) | ||
>config : Symbol(config, Decl(index.d.ts, 3, 32)) | ||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) | ||
|
||
export default replaceInFile; | ||
>replaceInFile : Symbol(replaceInFile, Decl(index.d.ts, 2, 34), Decl(index.d.ts, 4, 31)) | ||
|
||
namespace replaceInFile { | ||
>replaceInFile : Symbol(replaceInFile, Decl(index.d.ts, 2, 34), Decl(index.d.ts, 4, 31)) | ||
|
||
export function sync(config: unknown): unknown[]; | ||
>sync : Symbol(sync, Decl(index.d.ts, 6, 27)) | ||
>config : Symbol(config, Decl(index.d.ts, 7, 25)) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/namespaceNotMergedWithFunctionDefaultExport.types
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 @@ | ||
//// [tests/cases/compiler/namespaceNotMergedWithFunctionDefaultExport.ts] //// | ||
|
||
=== replace-in-file/types/index.d.ts === | ||
// repro from https://github.com/microsoft/TypeScript/issues/54342 | ||
|
||
declare module 'replace-in-file' { | ||
>'replace-in-file' : typeof import("replace-in-file") | ||
|
||
export function replaceInFile(config: unknown): Promise<unknown[]>; | ||
>replaceInFile : (config: unknown) => Promise<unknown[]> | ||
>config : unknown | ||
|
||
export default replaceInFile; | ||
>replaceInFile : typeof replaceInFile | ||
|
||
namespace replaceInFile { | ||
>replaceInFile : typeof replaceInFile | ||
|
||
export function sync(config: unknown): unknown[]; | ||
>sync : (config: unknown) => unknown[] | ||
>config : unknown | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/cases/compiler/namespaceNotMergedWithFunctionDefaultExport.ts
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,14 @@ | ||
// @moduleResolution: node10 | ||
// @module: commonjs | ||
|
||
// repro from https://github.com/microsoft/TypeScript/issues/54342 | ||
|
||
// @Filename: replace-in-file/types/index.d.ts | ||
declare module 'replace-in-file' { | ||
export function replaceInFile(config: unknown): Promise<unknown[]>; | ||
export default replaceInFile; | ||
|
||
namespace replaceInFile { | ||
export function sync(config: unknown): unknown[]; | ||
} | ||
} |
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.
I'm not experienced enough to know the right way to do this, but it does feel a little suspicious to export... I feel like I've seen a function that does something similar in the checker but I can't recall the name.
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 wanted to make sure the
container
used to check the implicit export rules is precisely the same the binder uses, and the binder uses those flags for that... I saw agetContainerNode
in services/utilities, andgetEnclosingBlockScopeContainer
in compiler/utilities, but those are different.