mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
modify error message
This commit is contained in:
@@ -7293,9 +7293,6 @@ namespace ts {
|
||||
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) {
|
||||
tryElaborateErrorsForPrimitivesAndObjects(source, target);
|
||||
}
|
||||
else if (source.symbol && source.flags & TypeFlags.ObjectType && globalObjectType === source) {
|
||||
reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
||||
}
|
||||
else if (source.symbol && source.flags & TypeFlags.Object && globalObjectType === source) {
|
||||
reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
|
||||
}
|
||||
@@ -18764,7 +18761,12 @@ namespace ts {
|
||||
|
||||
const container = node.parent.kind === SyntaxKind.SourceFile ? <SourceFile>node.parent : <ModuleDeclaration>node.parent.parent;
|
||||
if (container.kind === SyntaxKind.ModuleDeclaration && !isAmbientModule(container)) {
|
||||
error(node, Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
|
||||
if (node.isExportEquals) {
|
||||
error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
|
||||
} else {
|
||||
error(node, Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// Grammar checking
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
"category": "Error",
|
||||
"code": 1062
|
||||
},
|
||||
"A default export can only be used in an ECMAScript-style module.": {
|
||||
"An export assignment cannot be used in a namespace.": {
|
||||
"category": "Error",
|
||||
"code": 1063
|
||||
},
|
||||
@@ -851,6 +851,10 @@
|
||||
"category": "Error",
|
||||
"code": 1317
|
||||
},
|
||||
"A default export can only be used in an ECMAScript-style module.": {
|
||||
"category": "Error",
|
||||
"code": 1318
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment10.ts(4,3): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment10.ts (1 errors) ====
|
||||
export default "123";
|
||||
namespace Foo {
|
||||
var foo;
|
||||
export foo;
|
||||
~~~~~~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
}
|
||||
16
tests/baselines/reference/parserExportAssignment10.js
Normal file
16
tests/baselines/reference/parserExportAssignment10.js
Normal file
@@ -0,0 +1,16 @@
|
||||
//// [parserExportAssignment10.ts]
|
||||
export default "123";
|
||||
namespace Foo {
|
||||
var foo;
|
||||
export foo;
|
||||
}
|
||||
|
||||
//// [parserExportAssignment10.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports["default"] = "123";
|
||||
var Foo;
|
||||
(function (Foo) {
|
||||
var foo;
|
||||
foo;
|
||||
})(Foo || (Foo = {}));
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment5.ts(2,5): error TS1063: A default export can only be used in an ECMAScript-style module.
|
||||
tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment5.ts(2,5): error TS1063: An export assignment cannot be used in a namespace.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment5.ts (1 errors) ====
|
||||
module M {
|
||||
export = A;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1063: A default export can only be used in an ECMAScript-style module.
|
||||
!!! error TS1063: An export assignment cannot be used in a namespace.
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts(2,3): error TS1063: A default export can only be used in an ECMAScript-style module.
|
||||
tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts(6,3): error TS1063: A default export can only be used in an ECMAScript-style module.
|
||||
tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts(2,3): error TS1318: A default export can only be used in an ECMAScript-style module.
|
||||
tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts(6,3): error TS1318: A default export can only be used in an ECMAScript-style module.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment9.ts (2 errors) ====
|
||||
namespace Foo {
|
||||
export default foo;
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1063: A default export can only be used in an ECMAScript-style module.
|
||||
!!! error TS1318: A default export can only be used in an ECMAScript-style module.
|
||||
}
|
||||
|
||||
module Bar {
|
||||
export default bar;
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1063: A default export can only be used in an ECMAScript-style module.
|
||||
!!! error TS1318: A default export can only be used in an ECMAScript-style module.
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export default "123";
|
||||
namespace Foo {
|
||||
var foo;
|
||||
export foo;
|
||||
}
|
||||
Reference in New Issue
Block a user