mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Fix for #2561
This commit is contained in:
@@ -11857,15 +11857,15 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
if (!nodeCanBeDecorated(node)) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Decorators_are_not_valid_here);
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
|
||||
}
|
||||
else if (languageVersion < ScriptTarget.ES5) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) {
|
||||
let accessors = getAllAccessorDeclarations((<ClassDeclaration>node.parent).members, <AccessorDeclaration>node);
|
||||
if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor
|
||||
|
||||
class C {
|
||||
@dec constructor() {}
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts(4,6): error TS1206: Decorators are not valid here.
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts(3,1): error TS1206: Decorators are not valid here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts (1 errors) ====
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
enum E {
|
||||
~
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
enum E {
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts(4,10): error TS1206: Decorators are not valid here.
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts(3,1): error TS1206: Decorators are not valid here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts (1 errors) ====
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
function F() {
|
||||
~
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
function F() {
|
||||
}
|
||||
@@ -10,8 +10,7 @@ tests/cases/conformance/decorators/invalid/decoratorOnImportEquals1.ts(8,5): err
|
||||
|
||||
module M2 {
|
||||
@dec
|
||||
~~~~
|
||||
import X = M1.X;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
import X = M1.X;
|
||||
}
|
||||
@@ -3,10 +3,9 @@ tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts(1,1): e
|
||||
|
||||
==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts (1 errors) ====
|
||||
@dec
|
||||
~~~~
|
||||
import lib = require('./decoratorOnImportEquals2_0');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
import lib = require('./decoratorOnImportEquals2_0');
|
||||
|
||||
declare function dec<T>(target: T): T;
|
||||
==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_0.ts (0 errors) ====
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts(4,11): error TS1206: Decorators are not valid here.
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts(3,1): error TS1206: Decorators are not valid here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts (1 errors) ====
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
interface I {
|
||||
~
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
interface I {
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts(4,8): error TS1206: Decorators are not valid here.
|
||||
tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts(3,1): error TS1206: Decorators are not valid here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts (1 errors) ====
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
module M {
|
||||
~
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
module M {
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ tests/cases/conformance/decorators/invalid/decoratorOnTypeAlias.ts(3,1): error T
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
~~~~
|
||||
type T = number;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
type T = number;
|
||||
@@ -5,7 +5,6 @@ tests/cases/conformance/decorators/invalid/decoratorOnVar.ts(3,1): error TS1206:
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
~~~~
|
||||
var x: number;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
~
|
||||
!!! error TS1206: Decorators are not valid here.
|
||||
var x: number;
|
||||
Reference in New Issue
Block a user