This commit is contained in:
Ron Buckton 2015-04-02 12:05:56 -07:00
parent d9078e9eaa
commit f15ff32d5c
10 changed files with 26 additions and 30 deletions

View File

@ -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;

View File

@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor
class C {
@dec constructor() {}
~~~~~~~~~~~~~~~~~~~~~
~
!!! error TS1206: Decorators are not valid here.
}

View File

@ -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 {
}

View File

@ -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() {
}

View File

@ -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;
}

View File

@ -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) ====

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -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;

View File

@ -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;