mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05:00
Report a semantic error for an arrow function with a "this" parameter.
Fixes #9744.
This commit is contained in:
@@ -21857,6 +21857,9 @@ namespace ts {
|
||||
if (func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.ConstructSignature || func.kind === SyntaxKind.ConstructorType) {
|
||||
error(node, Diagnostics.A_constructor_cannot_have_a_this_parameter);
|
||||
}
|
||||
if (func.kind === SyntaxKind.ArrowFunction) {
|
||||
error(node, Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
|
||||
}
|
||||
}
|
||||
|
||||
// Only check rest parameter type if it's not a binding pattern. Since binding patterns are
|
||||
|
||||
@@ -2417,6 +2417,10 @@
|
||||
"category": "Error",
|
||||
"code": 2729
|
||||
},
|
||||
"An arrow function cannot have a 'this' parameter.": {
|
||||
"category": "Error",
|
||||
"code": 2730
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -3537,8 +3537,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
// If we had "(" followed by something that's not an identifier,
|
||||
// then this definitely doesn't look like a lambda.
|
||||
if (!isIdentifier()) {
|
||||
// then this definitely doesn't look like a lambda. "this" is not
|
||||
// valid, but we want to parse it and then give a semantic error.
|
||||
if (!isIdentifier() && second !== SyntaxKind.ThisKeyword) {
|
||||
return Tristate.False;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user