-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Allow decorators in JavaScript files #6881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f601e6d
ed7abcc
fb474d1
a4d7883
fe60490
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 { | ||
| ~ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's kind of weird that we error on the node instead of the decorator itself. We should consider that in a separate change. |
||
| !!! 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. | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| === tests/cases/compiler/a.js === | ||
| @internal class C { } | ||
| >C : Symbol(C, Decl(a.js, 0, 0)) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| === tests/cases/compiler/a.js === | ||
| @internal class C { } | ||
| >internal : any | ||
| >C : C | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // @allowJs: true | ||
| // @noEmit: true | ||
| // @experimentalDecorators: true | ||
| // @filename: a.js | ||
| @internal class C { } | ||
| @internal class C { } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,8 @@ | ||
| /// <reference path="fourslash.ts" /> | ||
|
|
||
| // @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 | ||
| } | ||
| ]`); | ||
| verify.getSemanticDiagnostics(`[]`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider just |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a non-standard feature, we should ask you to set a flag.. i.e. error if the flag is not set, and ask the user to specify the flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm. I'm conflicted on this one, as it seems maybe a little user hostile. (Kind of like we used to require a 'module' setting for you to write a module). Its not like they are going to write valid decorator syntax by accident, they opt in to decorators by virtue of writing one, and there is only one setting for the config option (
true), but we'd go make them add a config file and the option anyway, (even though for many Salsa users they are just editing code, not compiling).On the other hand, I get that the feature is "experimental" and we have precedent. Let's chat tomorrow, and I'll try and prepare the change anyway in the meantime. ( @egamma Any strong thoughts?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am just worried of breaking these users later with no warning. the switch is a implicit agreement that you may be broken. not sure if this changes your feelings when you really are broken though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only strong feeling is that showing an error is too much, showing a warning that this is an experimental feature would be more appropriate. But then the warning has to tell me how to get rid of it.