-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Fix error on duplicate commonjs exports #40545
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| //// [moduleExportAliasElementAccessExpression.js] | ||
| function D () { } | ||
| exports["D"] = D; | ||
|
|
||
|
|
||
| //// [moduleExportAliasElementAccessExpression.js] | ||
| function D() { } | ||
| exports["D"] = D; | ||
|
|
||
|
|
||
| //// [moduleExportAliasElementAccessExpression.d.ts] | ||
| export function D(): void; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js(1,9): error TS2300: Duplicate identifier 'apply'. | ||
| tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js(3,1): error TS2322: Type '() => void' is not assignable to type 'undefined'. | ||
| tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js(3,9): error TS2300: Duplicate identifier 'apply'. | ||
|
|
||
|
|
||
| ==== tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js (3 errors) ==== | ||
| exports.apply = undefined; | ||
| ~~~~~ | ||
| !!! error TS2300: Duplicate identifier 'apply'. | ||
| function a() { } | ||
| exports.apply = a; | ||
| ~~~~~~~~~~~~~ | ||
| !!! error TS2322: Type '() => void' is not assignable to type 'undefined'. | ||
| ~~~~~ | ||
| !!! error TS2300: Duplicate identifier 'apply'. | ||
|
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. To get rid of this error, we can defer detection of this case in the binder by removing the offending case from I think this pattern is actually super common, considering it's our current emit for cjs, so we should probably invest the effort into making it work smoothly.
Member
Author
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. Per our discussion, I switched this to None for the beta. It turns out that the checker already issues an error in this case, but we can add an exclusion for |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| //// [moduleExportAliasDuplicateAlias.js] | ||
| exports.apply = undefined; | ||
| function a() { } | ||
| exports.apply = a; | ||
|
|
||
|
|
||
| //// [moduleExportAliasDuplicateAlias.js] | ||
| exports.apply = undefined; | ||
| function a() { } | ||
| exports.apply = a; | ||
|
|
||
|
|
||
| //// [moduleExportAliasDuplicateAlias.d.ts] | ||
| export { undefined as apply }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| === tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js === | ||
| exports.apply = undefined; | ||
| >exports.apply : Symbol(apply, Decl(moduleExportAliasDuplicateAlias.js, 0, 0)) | ||
| >exports : Symbol(apply, Decl(moduleExportAliasDuplicateAlias.js, 0, 0)) | ||
| >apply : Symbol(apply, Decl(moduleExportAliasDuplicateAlias.js, 0, 0)) | ||
| >undefined : Symbol(apply) | ||
|
|
||
| function a() { } | ||
| >a : Symbol(a, Decl(moduleExportAliasDuplicateAlias.js, 0, 26)) | ||
|
|
||
| exports.apply = a; | ||
| >exports.apply : Symbol(apply, Decl(moduleExportAliasDuplicateAlias.js, 0, 0)) | ||
| >exports : Symbol(apply, Decl(moduleExportAliasDuplicateAlias.js, 1, 16)) | ||
| >apply : Symbol(apply, Decl(moduleExportAliasDuplicateAlias.js, 1, 16)) | ||
| >a : Symbol(a, Decl(moduleExportAliasDuplicateAlias.js, 0, 26)) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| === tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias.js === | ||
| exports.apply = undefined; | ||
| >exports.apply = undefined : undefined | ||
| >exports.apply : undefined | ||
| >exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias") | ||
| >apply : undefined | ||
| >undefined : undefined | ||
|
|
||
| function a() { } | ||
| >a : () => void | ||
|
|
||
| exports.apply = a; | ||
| >exports.apply = a : () => void | ||
| >exports.apply : undefined | ||
| >exports : typeof import("tests/cases/conformance/salsa/moduleExportAliasDuplicateAlias") | ||
| >apply : undefined | ||
| >a : () => void | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // @noEmit: true | ||
| // @declaration: true | ||
| // @checkJs: true | ||
| // @filename: moduleExportAliasElementAccessExpression.js | ||
| // @outdir: out | ||
|
|
||
| function D () { } | ||
| exports["D"] = D; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // @checkJs: true | ||
| // @declaration: true | ||
| // @filename: moduleExportAliasDuplicateAlias.js | ||
| // @outdir: out | ||
| exports.apply = undefined; | ||
| function a() { } | ||
| exports.apply = a; |
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.
And non-identifier names, like
"A B", emit as...what? Probably needs a test.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.
_A_B. I added a test the in the bug, but I guess I can add it here.