-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Report error if exports or require is used for declaration name in external module #569
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
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
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/collisionExportsRequireAndAlias.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,20 @@ | ||
| ==== tests/cases/compiler/collisionExportsRequireAndAlias_file2.ts (2 errors) ==== | ||
| import require = require('collisionExportsRequireAndAlias_file1'); // Error | ||
| ~~~~~~~ | ||
| !!! Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of an external module. | ||
| import exports = require('collisionExportsRequireAndAlias_file3333'); // Error | ||
| ~~~~~~~ | ||
| !!! Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of an external module. | ||
| export function foo() { | ||
| require.bar(); | ||
| } | ||
| export function foo2() { | ||
| exports.bar2(); | ||
| } | ||
| ==== tests/cases/compiler/collisionExportsRequireAndAlias_file1.ts (0 errors) ==== | ||
| export function bar() { | ||
| } | ||
|
|
||
| ==== tests/cases/compiler/collisionExportsRequireAndAlias_file3333.ts (0 errors) ==== | ||
| export function bar2() { | ||
| } |
63 changes: 41 additions & 22 deletions
63
tests/baselines/reference/collisionExportsRequireAndAlias.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 |
|---|---|---|
| @@ -1,23 +1,42 @@ | ||
| //// [collisionExportsRequireAndAlias.ts] | ||
| // TODO: re-enable, fails when run in the browser with full compiler suite, but not when run alone | ||
|
|
||
| ////@module: amd | ||
| //// @Filename: collisionExportsRequireAndAlias_file1.ts | ||
| //export function bar() { | ||
| //} | ||
|
|
||
| //// @Filename: collisionExportsRequireAndAlias_file3333.ts | ||
| //export function bar2() { | ||
| //} | ||
| //// @Filename: collisionExportsRequireAndAlias_file2.ts | ||
| //import require = require('collisionExportsRequireAndAlias_file1'); // Error | ||
| //import exports = require('collisionExportsRequireAndAlias_file3333'); // Error | ||
| //export function foo() { | ||
| // require.bar(); | ||
| //} | ||
| //export function foo2() { | ||
| // exports.bar2(); | ||
| //} | ||
| //// [tests/cases/compiler/collisionExportsRequireAndAlias.ts] //// | ||
|
|
||
| //// [collisionExportsRequireAndAlias.js] | ||
| // TODO: re-enable, fails when run in the browser with full compiler suite, but not when run alone | ||
| //// [collisionExportsRequireAndAlias_file1.ts] | ||
| export function bar() { | ||
| } | ||
|
|
||
| //// [collisionExportsRequireAndAlias_file3333.ts] | ||
| export function bar2() { | ||
| } | ||
| //// [collisionExportsRequireAndAlias_file2.ts] | ||
| import require = require('collisionExportsRequireAndAlias_file1'); // Error | ||
| import exports = require('collisionExportsRequireAndAlias_file3333'); // Error | ||
| export function foo() { | ||
| require.bar(); | ||
| } | ||
| export function foo2() { | ||
| exports.bar2(); | ||
| } | ||
|
|
||
| //// [collisionExportsRequireAndAlias_file1.js] | ||
| define(["require", "exports"], function (require, exports) { | ||
| function bar() { | ||
| } | ||
| exports.bar = bar; | ||
| }); | ||
| //// [collisionExportsRequireAndAlias_file3333.js] | ||
| define(["require", "exports"], function (require, exports) { | ||
| function bar2() { | ||
| } | ||
| exports.bar2 = bar2; | ||
| }); | ||
| //// [collisionExportsRequireAndAlias_file2.js] | ||
| define(["require", "exports", 'collisionExportsRequireAndAlias_file1', 'collisionExportsRequireAndAlias_file3333'], function (require, exports, require, exports) { | ||
| function foo() { | ||
| require.bar(); | ||
| } | ||
| exports.foo = foo; | ||
| function foo2() { | ||
| exports.bar2(); | ||
| } | ||
| exports.foo2 = foo2; | ||
| }); |
21 changes: 0 additions & 21 deletions
21
tests/baselines/reference/collisionExportsRequireAndAlias.types
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
tests/baselines/reference/collisionExportsRequireAndAmbientClass.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,50 @@ | ||
| //// [tests/cases/compiler/collisionExportsRequireAndAmbientClass.ts] //// | ||
|
|
||
| //// [collisionExportsRequireAndAmbientClass_externalmodule.ts] | ||
| export declare class require { | ||
| } | ||
| export declare class exports { | ||
| } | ||
| declare module m1 { | ||
| class require { | ||
| } | ||
| class exports { | ||
| } | ||
| } | ||
| module m2 { | ||
| export declare class require { | ||
| } | ||
| export declare class exports { | ||
| } | ||
| } | ||
|
|
||
| //// [collisionExportsRequireAndAmbientClass_globalFile.ts] | ||
| declare class require { | ||
| } | ||
| declare class exports { | ||
| } | ||
| declare module m3 { | ||
| class require { | ||
| } | ||
| class exports { | ||
| } | ||
| } | ||
| module m4 { | ||
| export declare class require { | ||
| } | ||
| export declare class exports { | ||
| } | ||
| var a = 10; | ||
| } | ||
|
|
||
| //// [collisionExportsRequireAndAmbientClass_externalmodule.js] | ||
| define(["require", "exports"], function (require, exports) { | ||
| var m2; | ||
| (function (m2) { | ||
| })(m2 || (m2 = {})); | ||
| }); | ||
| //// [collisionExportsRequireAndAmbientClass_globalFile.js] | ||
| var m4; | ||
| (function (m4) { | ||
| var a = 10; | ||
| })(m4 || (m4 = {})); |
57 changes: 57 additions & 0 deletions
57
tests/baselines/reference/collisionExportsRequireAndAmbientClass.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,57 @@ | ||
| === tests/cases/compiler/collisionExportsRequireAndAmbientClass_externalmodule.ts === | ||
| export declare class require { | ||
| >require : require | ||
| } | ||
| export declare class exports { | ||
| >exports : exports | ||
| } | ||
| declare module m1 { | ||
| >m1 : typeof m1 | ||
|
|
||
| class require { | ||
| >require : require | ||
| } | ||
| class exports { | ||
| >exports : exports | ||
| } | ||
| } | ||
| module m2 { | ||
| >m2 : typeof m2 | ||
|
|
||
| export declare class require { | ||
| >require : require | ||
| } | ||
| export declare class exports { | ||
| >exports : exports | ||
| } | ||
| } | ||
|
|
||
| === tests/cases/compiler/collisionExportsRequireAndAmbientClass_globalFile.ts === | ||
| declare class require { | ||
| >require : require | ||
| } | ||
| declare class exports { | ||
| >exports : exports | ||
| } | ||
| declare module m3 { | ||
| >m3 : typeof m3 | ||
|
|
||
| class require { | ||
| >require : require | ||
| } | ||
| class exports { | ||
| >exports : exports | ||
| } | ||
| } | ||
| module m4 { | ||
| >m4 : typeof m4 | ||
|
|
||
| export declare class require { | ||
| >require : require | ||
| } | ||
| export declare class exports { | ||
| >exports : exports | ||
| } | ||
| var a = 10; | ||
| >a : number | ||
| } |
72 changes: 72 additions & 0 deletions
72
tests/baselines/reference/collisionExportsRequireAndAmbientEnum.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,72 @@ | ||
| //// [tests/cases/compiler/collisionExportsRequireAndAmbientEnum.ts] //// | ||
|
|
||
| //// [collisionExportsRequireAndAmbientEnum_externalmodule.ts] | ||
| export declare enum require { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| export declare enum exports { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| declare module m1 { | ||
| enum require { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| enum exports { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| } | ||
| module m2 { | ||
| export declare enum require { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| export declare enum exports { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| } | ||
|
|
||
| //// [collisionExportsRequireAndAmbientEnum_globalFile.ts] | ||
| declare enum require { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| declare enum exports { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| declare module m3 { | ||
| enum require { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| enum exports { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| } | ||
| module m4 { | ||
| export declare enum require { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| export declare enum exports { | ||
| _thisVal1, | ||
| _thisVal2, | ||
| } | ||
| } | ||
|
|
||
| //// [collisionExportsRequireAndAmbientEnum_externalmodule.js] | ||
| define(["require", "exports"], function (require, exports) { | ||
| var m2; | ||
| (function (m2) { | ||
| })(m2 || (m2 = {})); | ||
| }); | ||
| //// [collisionExportsRequireAndAmbientEnum_globalFile.js] | ||
| var m4; | ||
| (function (m4) { | ||
| })(m4 || (m4 = {})); |
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.
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.
typo: shouldn't