Add specific error messages for out-of-place this

Also remove lint in checker.
This commit is contained in:
Nathan Shively-Sanders
2016-02-04 16:01:10 -08:00
parent 8c87da523b
commit 2f74da112d
5 changed files with 69 additions and 33 deletions

View File

@@ -11624,8 +11624,11 @@ namespace ts {
error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
}
if ((<Identifier>node.name).text === "this") {
if(indexOf(func.parameters, node) !== 0 || func.kind === SyntaxKind.Constructor) {
error(node, Diagnostics.this_cannot_be_referenced_in_current_location);
if (indexOf(func.parameters, node) !== 0) {
error(node, Diagnostics.this_parameter_must_be_the_first_parameter);
}
if (func.kind === SyntaxKind.Constructor) {
error(node, Diagnostics.A_constructor_cannot_have_a_this_parameter);
}
}

View File

@@ -1827,6 +1827,14 @@
"category": "Error",
"code": 2672
},
"'this' parameter must be the first parameter.": {
"category": "Error",
"code": 2673
},
"A constructor cannot have a 'this' parameter.": {
"category": "Error",
"code": 2674
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000