diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6b43b3802c2a4..7b9cc76b11b8c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12740,7 +12740,7 @@ namespace ts { } if (!compilerOptions.experimentalDecorators) { - error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } if (compilerOptions.emitDecoratorMetadata) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 25b86e67d34fe..1829e99eb1664 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -687,7 +687,7 @@ "category": "Error", "code": 1218 }, - "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": { + "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.": { "category": "Error", "code": 1219 }, @@ -2729,11 +2729,6 @@ "category": "Error", "code": 8016 }, - "'decorators' can only be used in a .ts file.": { - "category": "Error", - "code": 8017 - }, - "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": { "category": "Error", "code": 9002 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7a2e65ed33bad..a51b3eed4bf49 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1169,7 +1169,9 @@ namespace ts { diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; case SyntaxKind.Decorator: - diagnostics.push(createDiagnosticForNode(node, Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + if (!options.experimentalDecorators) { + diagnostics.push(createDiagnosticForNode(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + } return true; } diff --git a/tests/baselines/reference/generatorTypeCheck39.errors.txt b/tests/baselines/reference/generatorTypeCheck39.errors.txt index ae24837f712b5..aabb5a47a355d 100644 --- a/tests/baselines/reference/generatorTypeCheck39.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck39.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(5,16): error TS1163: A 'yield' expression is only allowed in a generator body. -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(6,11): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(6,11): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(7,13): error TS1163: A 'yield' expression is only allowed in a generator body. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck39.ts(7,13): erro !!! error TS1163: A 'yield' expression is only allowed in a generator body. class C { ~ -!!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. +!!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. x = yield 0; ~~~~~ !!! error TS1163: A 'yield' expression is only allowed in a generator body. diff --git a/tests/baselines/reference/generatorTypeCheck59.errors.txt b/tests/baselines/reference/generatorTypeCheck59.errors.txt index d817980382177..cba90154701af 100644 --- a/tests/baselines/reference/generatorTypeCheck59.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck59.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator body. -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(4,9): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(4,9): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts (2 errors) ==== @@ -10,6 +10,6 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(4,9): error !!! error TS1163: A 'yield' expression is only allowed in a generator body. m() { } ~ -!!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. +!!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. }; } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck61.errors.txt b/tests/baselines/reference/generatorTypeCheck61.errors.txt index b38e96d31ce13..ccc99f7ffbd34 100644 --- a/tests/baselines/reference/generatorTypeCheck61.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck61.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck61.ts(2,7): error TS1163: A 'yield' expression is only allowed in a generator body. -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck61.ts(3,11): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck61.ts(3,11): error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck61.ts (2 errors) ==== @@ -9,5 +9,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck61.ts(3,11): erro !!! error TS1163: A 'yield' expression is only allowed in a generator body. class C {}; ~ -!!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. +!!! error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning. } \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationDecoratorSyntax.errors.txt b/tests/baselines/reference/jsFileCompilationDecoratorSyntax.errors.txt deleted file mode 100644 index a39d2e1665cf9..0000000000000 --- a/tests/baselines/reference/jsFileCompilationDecoratorSyntax.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -tests/cases/compiler/a.js(1,1): error TS8017: 'decorators' can only be used in a .ts file. - - -!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -==== tests/cases/compiler/a.js (1 errors) ==== - @internal class C { } - ~~~~~~~~~ -!!! error TS8017: 'decorators' can only be used in a .ts file. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationDecoratorSyntax.symbols b/tests/baselines/reference/jsFileCompilationDecoratorSyntax.symbols new file mode 100644 index 0000000000000..02973b4314766 --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationDecoratorSyntax.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/a.js === +@internal class C { } +>C : Symbol(C, Decl(a.js, 0, 0)) + diff --git a/tests/baselines/reference/jsFileCompilationDecoratorSyntax.types b/tests/baselines/reference/jsFileCompilationDecoratorSyntax.types new file mode 100644 index 0000000000000..ee1f14129d5fb --- /dev/null +++ b/tests/baselines/reference/jsFileCompilationDecoratorSyntax.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/a.js === +@internal class C { } +>internal : any +>C : C + diff --git a/tests/cases/compiler/jsFileCompilationDecoratorSyntax.ts b/tests/cases/compiler/jsFileCompilationDecoratorSyntax.ts index 2ef95db01fe1f..6627fb5dca036 100644 --- a/tests/cases/compiler/jsFileCompilationDecoratorSyntax.ts +++ b/tests/cases/compiler/jsFileCompilationDecoratorSyntax.ts @@ -1,3 +1,5 @@ // @allowJs: true +// @noEmit: true +// @experimentalDecorators: true // @filename: a.js -@internal class C { } \ No newline at end of file +@internal class C { } diff --git a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics21.ts b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics21.ts index b71677554a215..8a7120acbb371 100644 --- a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics21.ts +++ b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics21.ts @@ -1,15 +1,8 @@ /// // @allowJs: true +// @experimentalDecorators: true // @Filename: a.js //// @internal class C {} -verify.getSemanticDiagnostics(`[ - { - "message": "'decorators' can only be used in a .ts file.", - "start": 0, - "length": 9, - "category": "error", - "code": 8017 - } -]`); \ No newline at end of file +verify.getSemanticDiagnostics(`[]`);