Skip to content

Commit

Permalink
split error message
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed Sep 14, 2016
1 parent e61a7ee commit dceba92
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
6 changes: 5 additions & 1 deletion src/compiler/checker.ts
Expand Up @@ -14186,7 +14186,11 @@ namespace ts {
// see: https://github.com/Microsoft/TypeScript/issues/442
const forbiddenNames = ["length", "name", "arguments", "caller"];
if (forbiddenNames.indexOf(name) !== -1) {
return grammarErrorOnNode(node, Diagnostics._0_is_not_allowed_to_be_used_as_a_name_of_a_static_property_or_method_in_a_class, name);
if (languageVersion < ScriptTarget.ES6) {
return grammarErrorOnNode(node, Diagnostics._0_is_not_allowed_to_be_used_as_a_name_of_a_static_property_or_method_in_a_class_for_target_es5_2695, name);
} else {
return grammarErrorOnNode(node, Diagnostics._0_is_not_allowed_to_be_used_as_a_name_of_a_static_property_in_a_class_for_target_es6_and_higher_2696, name);
}
}

return false;
Expand Down
6 changes: 5 additions & 1 deletion src/compiler/diagnosticMessages.json
Expand Up @@ -1955,10 +1955,14 @@
"category": "Error",
"code": 2694
},
"'{0}' is not allowed to be used as a name of a static property or method in a class.": {
"'{0}' is not allowed to be used as a name of a static property or method in a class for target ES5.": {
"category": "Error",
"code": 2695
},
"'{0}' is not allowed to be used as a name of a static property in a class for target ES6 and higher.": {
"category": "Error",
"code": 2696
},

"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
Expand Down
@@ -1,60 +1,60 @@
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(3,5): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(4,5): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(5,5): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(6,5): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(8,9): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(9,9): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(10,9): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(11,9): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(16,12): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(17,12): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(18,12): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(19,12): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(3,5): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(4,5): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(5,5): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(6,5): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(8,9): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(9,9): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(10,9): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(11,9): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(16,12): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(17,12): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(18,12): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class for target ES5.
tests/cases/compiler/checkGrammarStaticMemberName_es5.ts(19,12): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class for target ES5.


==== tests/cases/compiler/checkGrammarStaticMemberName_es5.ts (12 errors) ====

class static_property {
static length = 1;
~~~~~~~~~~~~~~~~~~
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class for target ES5.
static name = 1;
~~~~~~~~~~~~~~~~
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class for target ES5.
static arguments = 1;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class for target ES5.
static caller = 1;
~~~~~~~~~~~~~~~~~~
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class for target ES5.
static foo = {
["length"]: 1,
~~~~~~~~~~
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class for target ES5.
["name"]: 1,
~~~~~~~~
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class for target ES5.
["arguments"]: 1,
~~~~~~~~~~~~~
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class for target ES5.
["caller"]: 1,
~~~~~~~~~~
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class for target ES5.
};
}

class static_method {
static length() { return 1; }
~~~~~~
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class for target ES5.
static name() { return 1; }
~~~~
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class for target ES5.
static arguments() { return 1; }
~~~~~~~~~
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class for target ES5.
static caller() { return 1; }
~~~~~~
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class for target ES5.
}

@@ -1,41 +1,41 @@
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(3,5): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(4,5): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(5,5): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(6,5): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(8,9): error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(9,9): error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(10,9): error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(11,9): error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(3,5): error TS2695: 'length' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(4,5): error TS2695: 'name' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(5,5): error TS2695: 'arguments' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(6,5): error TS2695: 'caller' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(8,9): error TS2695: 'length' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(9,9): error TS2695: 'name' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(10,9): error TS2695: 'arguments' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
tests/cases/compiler/checkGrammarStaticMemberName_es6.ts(11,9): error TS2695: 'caller' is not allowed to be used as a name of a static property in a class for target ES6 and higher.


==== tests/cases/compiler/checkGrammarStaticMemberName_es6.ts (8 errors) ====

class static_property {
static length = 1;
~~~~~~~~~~~~~~~~~~
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'length' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
static name = 1;
~~~~~~~~~~~~~~~~
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'name' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
static arguments = 1;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
static caller = 1;
~~~~~~~~~~~~~~~~~~
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
static foo = {
["length"]: 1,
~~~~~~~~~~
!!! error TS2695: 'length' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'length' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
["name"]: 1,
~~~~~~~~
!!! error TS2695: 'name' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'name' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
["arguments"]: 1,
~~~~~~~~~~~~~
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'arguments' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
["caller"]: 1,
~~~~~~~~~~
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property or method in a class.
!!! error TS2695: 'caller' is not allowed to be used as a name of a static property in a class for target ES6 and higher.
};
}

Expand Down

0 comments on commit dceba92

Please sign in to comment.