Skip to content

Commit

Permalink
Fix for #2561
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Apr 2, 2015
1 parent d9078e9 commit f15ff32
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor

class C {
@dec constructor() {}
~~~~~~~~~~~~~~~~~~~~~
~
!!! error TS1206: Decorators are not valid here.
}
6 changes: 3 additions & 3 deletions tests/baselines/reference/decoratorOnEnum.errors.txt
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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() {
}
5 changes: 2 additions & 3 deletions tests/baselines/reference/decoratorOnImportEquals1.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 2 additions & 3 deletions tests/baselines/reference/decoratorOnImportEquals2.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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) ====
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/decoratorOnInterface.errors.txt
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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 {

}
7 changes: 3 additions & 4 deletions tests/baselines/reference/decoratorOnTypeAlias.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 3 additions & 4 deletions tests/baselines/reference/decoratorOnVar.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f15ff32

Please sign in to comment.