-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Fix: Consult referenced project options for synthetic default export eligibility #63038
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
+126
−0
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4d6c59b
Initial plan
Copilot 0351c51
Implement fix for synthetic default exports with project references
Copilot 071043f
Remove redundant condition check in canHaveSyntheticDefault
Copilot bcd143a
Run formatter to fix trailing whitespace
Copilot 01c3f08
Accept new baseline for default-import-interop test
Copilot 4e968bb
Replace fourslash test with proper tsc test that reproduces the bug
Copilot d392ebd
Use getEmitModuleKind for referenced project options
Copilot 5a2ac97
Use getEmitModuleFormatOfFile for project reference declaration files
Copilot 0d532eb
Apply getEmitModuleFormatOfFile only for project reference declaratio…
Copilot d7ac3ad
Use ES module range check and try both redirect mappings
Copilot a99a489
Improve test coverage
andrewbranch 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,8 @@ declare const console: { log(msg: any): void; }; | |
| Output:: | ||
| app/src/index.ts(2,28): error TS2613: Module '"/home/src/workspaces/project/app/src/local"' has no default export. Did you mean to use 'import { local } from "/home/src/workspaces/project/app/src/local"' instead? | ||
| app/src/index.ts(3,28): error TS2613: Module '"/home/src/workspaces/project/node_modules/esm-package/index"' has no default export. Did you mean to use 'import { esm } from "/home/src/workspaces/project/node_modules/esm-package/index"' instead? | ||
| app/src/index.ts(4,28): error TS1192: Module '"/home/src/workspaces/project/lib/dist/a"' has no default export. | ||
| app/src/index.ts(5,28): error TS1192: Module '"/home/src/workspaces/project/lib/dist/a"' has no default export. | ||
|
Comment on lines
+89
to
+90
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The presence of these errors was actually always asserted in the test content (lines 66–67 in the baseline). Not sure if this used to work and regressed without noticing or what, but this baseline change matches the original intention. |
||
|
|
||
|
|
||
| //// [/home/src/workspaces/project/app/dist/local.js] | ||
|
|
||
62 changes: 62 additions & 0 deletions
62
...ctReferences/referenced-project-with-esnext-module-disallows-synthetic-default-imports.js
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,62 @@ | ||
| currentDirectory:: /home/src/workspaces/project useCaseSensitiveFileNames:: false | ||
| Input:: | ||
| //// [/home/src/workspaces/project/lib/tsconfig.json] | ||
| { | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| "declaration": true, | ||
| "module": "esnext", | ||
| "moduleResolution": "bundler" | ||
| } | ||
| } | ||
|
|
||
| //// [/home/src/workspaces/project/lib/utils.ts] | ||
| export const test = () => 'test'; | ||
|
|
||
| //// [/home/src/workspaces/project/lib/utils.d.ts] | ||
| export declare const test: () => string; | ||
|
|
||
| //// [/home/src/workspaces/project/app/tsconfig.json] | ||
| { | ||
| "compilerOptions": { | ||
| "module": "esnext", | ||
| "moduleResolution": "bundler" | ||
| }, | ||
| "references": [ | ||
| { | ||
| "path": "../lib" | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| //// [/home/src/workspaces/project/app/index.ts] | ||
| import Test from '../lib/utils'; | ||
| console.log(Test.test()); | ||
|
|
||
| //// [/home/src/tslibs/TS/Lib/lib.d.ts] | ||
| interface Boolean {} | ||
| interface Function {} | ||
| interface CallableFunction {} | ||
| interface NewableFunction {} | ||
| interface IArguments {} | ||
| interface Number { toExponential: any; } | ||
| interface Object {} | ||
| interface RegExp {} | ||
| interface String { charAt: any; } | ||
| interface Array<T> { length: number; [n: number]: T; } | ||
| interface ReadonlyArray<T> {} | ||
| declare const console: { log(msg: any): void; }; | ||
|
|
||
|
|
||
| /home/src/tslibs/TS/Lib/tsc.js --p app --pretty false | ||
| Output:: | ||
| app/index.ts(1,8): error TS1192: Module '"/home/src/workspaces/project/lib/utils"' has no default export. | ||
|
|
||
|
|
||
| //// [/home/src/workspaces/project/app/index.js] | ||
| import Test from '../lib/utils'; | ||
| console.log(Test.test()); | ||
|
|
||
|
|
||
|
|
||
| exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.