8000 Allow decorators in JavaScript files · nycdotnet/TypeScript@d396f6e · GitHub
[go: up one dir, main page]

Skip to content

Commit d396f6e

Browse files
committed
Allow decorators in JavaScript files
(cherry picked from commit f601e6d)
1 parent ddc0778 commit d396f6e

7 files changed

+11
-26
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,11 +2607,6 @@
26072607
"category": "Error",
26082608
"code": 8016
26092609
},
2610-
"'decorators' can only be used in a .ts file.": {
2611-
"category": "Error",
2612-
"code": 8017
2613-
},
2614-
26152610
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": {
26162611
"category": "Error",
26172612
"code": 9002

src/compiler/program.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,6 @@ namespace ts {
827827
let typeAssertionExpression = <TypeAssertion>node;
828828
diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
829829
return true;
830-
10000 case SyntaxKind.Decorator:
831-
diagnostics.push(createDiagnosticForNode(node, Diagnostics.decorators_can_only_be_used_in_a_ts_file));
832-
return true;
833830
}
834831

835832
return forEachChild(node, walk);

tests/baselines/reference/jsFileCompilationDecoratorSyntax.errors.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/compiler/a.js ===
2+
@internal class C { }
3+
>C : Symbol(C, Decl(a.js, 0, 0))
4+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/a.js ===
2+
@internal class C { }
3+
>internal : any
4+
>C : C
5+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// @allowJs: true
2+
// @noEmit: true
23
// @filename: a.js
34
@internal class C { }

tests/cases/fourslash/getJavaScriptSemanticDiagnostics21.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,4 @@
44
// @Filename: a.js
55
//// @internal class C {}
66

7-
verify.getSemanticDiagnostics(`[
8-
{
9-
"message": "'decorators' can only be used in a .ts file.",
10-
"start": 0,
11-
"length": 9,
12-
"category": "error",
13-
"code": 8017
14-
}
15-
]`);
7+
verify.getSemanticDiagnostics(`[]`);

0 commit comments

Comments
 (0)
0