Skip to content

Commit f601e6d

Browse files
committed
Allow decorators in JavaScript files
1 parent 977adde commit f601e6d

7 files changed

Lines changed: 11 additions & 26 deletions

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,11 +2729,6 @@
27292729
"category": "Error",
27302730
"code": 8016
27312731
},
2732-
"'decorators' can only be used in a .ts file.": {
2733-
"category": "Error",
2734-
"code": 8017
2735-
},
2736-
27372732
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": {
27382733
"category": "Error",
27392734
"code": 9002

src/compiler/program.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,9 +1168,6 @@ namespace ts {
11681168
let typeAssertionExpression = <TypeAssertion>node;
11691169
diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
11701170
return true;
1171-
case SyntaxKind.Decorator:
1172-
diagnostics.push(createDiagnosticForNode(node, Diagnostics.decorators_can_only_be_used_in_a_ts_file));
1173-
return true;
11741171
}
11751172

11761173
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)