mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 17:27:54 -05:00
Merge pull request #6797 from Microsoft/weReallyNeedANewSyntaxKindForTheseExports
Allow 'export default's in JS files without incorrect error
This commit is contained in:
@@ -734,8 +734,11 @@ namespace ts {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.import_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.export_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
if ((<ExportAssignment>node).isExportEquals) {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.export_can_only_be_used_in_a_ts_file));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
let classDeclaration = <ClassDeclaration>node;
|
||||
if (checkModifiers(classDeclaration.modifiers) ||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile01.js' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile01.js' because it would overwrite input file.
|
||||
==== tests/cases/conformance/salsa/myFile01.js (0 errors) ====
|
||||
|
||||
export default "hello";
|
||||
@@ -0,0 +1,7 @@
|
||||
error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile02.js' because it would overwrite input file.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'tests/cases/conformance/salsa/myFile02.js' because it would overwrite input file.
|
||||
==== tests/cases/conformance/salsa/myFile02.js (0 errors) ====
|
||||
|
||||
export default "hello";
|
||||
@@ -1,10 +1,9 @@
|
||||
tests/cases/compiler/a.js(1,22): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/compiler/a.js(3,1): error TS2528: A module cannot have multiple default exports.
|
||||
tests/cases/compiler/a.js(3,1): error TS8003: 'export=' can only be used in a .ts file.
|
||||
tests/cases/compiler/a.js(3,16): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (4 errors) ====
|
||||
==== tests/cases/compiler/a.js (3 errors) ====
|
||||
export default class a {
|
||||
~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
@@ -12,7 +11,5 @@ tests/cases/compiler/a.js(3,16): error TS1109: Expression expected.
|
||||
export default var a = 10;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS8003: 'export=' can only be used in a .ts file.
|
||||
~~~
|
||||
!!! error TS1109: Expression expected.
|
||||
6
tests/cases/conformance/salsa/exportDefaultInJsFile01.ts
Normal file
6
tests/cases/conformance/salsa/exportDefaultInJsFile01.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// @allowJS: true
|
||||
// @target: es3
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: myFile01.js
|
||||
export default "hello";
|
||||
6
tests/cases/conformance/salsa/exportDefaultInJsFile02.ts
Normal file
6
tests/cases/conformance/salsa/exportDefaultInJsFile02.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// @allowJS: true
|
||||
// @target: es2015
|
||||
// @module: es2015
|
||||
|
||||
// @filename: myFile02.js
|
||||
export default "hello";
|
||||
Reference in New Issue
Block a user