mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Remove duplicate check for misplaced parameter properties (taken care of by checkParameter)
This commit is contained in:
parent
40afe4a4dd
commit
ce596732ab
@ -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);
|
||||
}
|
||||
|
||||
@ -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.
|
||||
}
|
||||
@ -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.
|
||||
}
|
||||
@ -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.
|
||||
23
tests/baselines/reference/readonlyInNonPropertyParameters.js
Normal file
23
tests/baselines/reference/readonlyInNonPropertyParameters.js
Normal 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; });
|
||||
8
tests/cases/compiler/readonlyInNonPropertyParameters.ts
Normal file
8
tests/cases/compiler/readonlyInNonPropertyParameters.ts
Normal 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;
|
||||
Loading…
x
Reference in New Issue
Block a user