Skip to content

Commit f15ff32

Browse files
committed
Fix for #2561
1 parent d9078e9 commit f15ff32

10 files changed

+26
-30
lines changed

src/compiler/checker.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11857,15 +11857,15 @@ module ts {
1185711857
return false;
1185811858
}
1185911859
if (!nodeCanBeDecorated(node)) {
11860-
return grammarErrorOnNode(node, Diagnostics.Decorators_are_not_valid_here);
11860+
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
1186111861
}
1186211862
else if (languageVersion < ScriptTarget.ES5) {
11863-
return grammarErrorOnNode(node, Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher);
11863+
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher);
1186411864
}
1186511865
else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) {
1186611866
let accessors = getAllAccessorDeclarations((<ClassDeclaration>node.parent).members, <AccessorDeclaration>node);
1186711867
if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
11868-
return grammarErrorOnNode(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
11868+
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
1186911869
}
1187011870
}
1187111871
return false;

tests/baselines/reference/decoratorOnClassConstructor1.errors.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor
66

77
class C {
88
@dec constructor() {}
9-
~~~~~~~~~~~~~~~~~~~~~
9+
~
1010
!!! error TS1206: Decorators are not valid here.
1111
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts(4,6): error TS1206: Decorators are not valid here.
1+
tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts(3,1): error TS1206: Decorators are not valid here.
22

33

44
==== tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts (1 errors) ====
55
declare function dec<T>(target: T): T;
66

77
@dec
8-
enum E {
9-
~
8+
~
109
!!! error TS1206: Decorators are not valid here.
10+
enum E {
1111
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts(4,10): error TS1206: Decorators are not valid here.
1+
tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts(3,1): error TS1206: Decorators are not valid here.
22

33

44
==== tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts (1 errors) ====
55
declare function dec<T>(target: T): T;
66

77
@dec
8-
function F() {
9-
~
8+
~
109
!!! error TS1206: Decorators are not valid here.
10+
function F() {
1111
}

tests/baselines/reference/decoratorOnImportEquals1.errors.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ tests/cases/conformance/decorators/invalid/decoratorOnImportEquals1.ts(8,5): err
1010

1111
module M2 {
1212
@dec
13-
~~~~
14-
import X = M1.X;
15-
~~~~~~~~~~~~~~~~~~~~
13+
~
1614
!!! error TS1206: Decorators are not valid here.
15+
import X = M1.X;
1716
}

tests/baselines/reference/decoratorOnImportEquals2.errors.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts(1,1): e
33

44
==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts (1 errors) ====
55
@dec
6-
~~~~
7-
import lib = require('./decoratorOnImportEquals2_0');
8-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
~
97
!!! error TS1206: Decorators are not valid here.
8+
import lib = require('./decoratorOnImportEquals2_0');
109

1110
declare function dec<T>(target: T): T;
1211
==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_0.ts (0 errors) ====
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts(4,11): error TS1206: Decorators are not valid here.
1+
tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts(3,1): error TS1206: Decorators are not valid here.
22

33

44
==== tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts (1 errors) ====
55
declare function dec<T>(target: T): T;
66

77
@dec
8-
interface I {
9-
~
8+
~
109
!!! error TS1206: Decorators are not valid here.
10+
interface I {
1111
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts(4,8): error TS1206: Decorators are not valid here.
1+
tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts(3,1): error TS1206: Decorators are not valid here.
22

33

44
==== tests/cases/conformance/decorators/invalid/decoratorOnInternalModule.ts (1 errors) ====
55
declare function dec<T>(target: T): T;
66

77
@dec
8-
module M {
9-
~
8+
~
109
!!! error TS1206: Decorators are not valid here.
10+
module M {
1111

1212
}

tests/baselines/reference/decoratorOnTypeAlias.errors.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ tests/cases/conformance/decorators/invalid/decoratorOnTypeAlias.ts(3,1): error T
55
declare function dec<T>(target: T): T;
66

77
@dec
8-
~~~~
9-
type T = number;
10-
~~~~~~~~~~~~~~~~
11-
!!! error TS1206: Decorators are not valid here.
8+
~
9+
!!! error TS1206: Decorators are not valid here.
10+
type T = number;

tests/baselines/reference/decoratorOnVar.errors.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ tests/cases/conformance/decorators/invalid/decoratorOnVar.ts(3,1): error TS1206:
55
declare function dec<T>(target: T): T;
66

77
@dec
8-
~~~~
9-
var x: number;
10-
~~~~~~~~~~~~~~
11-
!!! error TS1206: Decorators are not valid here.
8+
~
9+
!!! error TS1206: Decorators are not valid here.
10+
var x: number;

0 commit comments

Comments
 (0)