Remove duplicate check for misplaced parameter properties (taken care of by checkParameter)

This commit is contained in:
Andy Hanson 2016-05-11 14:14:52 -07:00
parent 40afe4a4dd
commit ce596732ab
6 changed files with 52 additions and 14 deletions

View File

@ -18225,9 +18225,6 @@ namespace ts {
if (parameter.dotDotDotToken) {
return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_set_accessor_cannot_have_rest_parameter);
}
else if (parameter.flags & NodeFlags.Modifier) {
return grammarErrorOnNode(accessor.name, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
else if (parameter.questionToken) {
return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
}

View File

@ -1,20 +1,14 @@
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,9): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,11): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,16): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,18): error TS2369: A parameter property is only allowed in a constructor implementation.
==== tests/cases/compiler/accessorParameterAccessibilityModifier.ts (4 errors) ====
==== tests/cases/compiler/accessorParameterAccessibilityModifier.ts (2 errors) ====
class C {
set X(public v) { }
~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
static set X(public v2) { }
~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
}

View File

@ -1,12 +1,9 @@
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration15.ts(2,8): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration15.ts(2,12): error TS2369: A parameter property is only allowed in a constructor implementation.
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration15.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/MemberAccessorDeclarations/parserMemberAccessorDeclaration15.ts (1 errors) ====
class C {
set Foo(public a: number) { }
~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
}

View File

@ -0,0 +1,19 @@
tests/cases/compiler/readonlyInNonPropertyParameters.ts(4,9): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/readonlyInNonPropertyParameters.ts(5,8): error TS2369: A parameter property is only allowed in a constructor implementation.
tests/cases/compiler/readonlyInNonPropertyParameters.ts(7,2): error TS2369: A parameter property is only allowed in a constructor implementation.
==== tests/cases/compiler/readonlyInNonPropertyParameters.ts (3 errors) ====
// `readonly` won't work outside of property parameters
class X {
method(readonly x: number) {}
~~~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
set x(readonly value: number) {}
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
}
(readonly x) => 0;
~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.

View File

@ -0,0 +1,23 @@
//// [readonlyInNonPropertyParameters.ts]
// `readonly` won't work outside of property parameters
class X {
method(readonly x: number) {}
set x(readonly value: number) {}
}
(readonly x) => 0;
//// [readonlyInNonPropertyParameters.js]
// `readonly` won't work outside of property parameters
var X = (function () {
function X() {
}
X.prototype.method = function (x) { };
Object.defineProperty(X.prototype, "x", {
set: function (value) { },
enumerable: true,
configurable: true
});
return X;
}());
(function (x) { return 0; });

View File

@ -0,0 +1,8 @@
//@target: ES5
// `readonly` won't work outside of property parameters
class X {
method(readonly x: number) {}
set x(readonly value: number) {}
}
(readonly x) => 0;