Skip to content
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

Salsa - incorrect error message when using ES7 decorators in a .js file #6872

Closed
egamma opened this issue Feb 3, 2016 · 19 comments
Closed
Assignees
Labels
Bug A bug in TypeScript

Comments

@egamma
Copy link
Member

egamma commented Feb 3, 2016

See the error message in the screen shot below. It is from a .js project that is using ES7 features using bable to downlevel compile it.

If I'm a bable user I consider the error message as wrong. I've tried to enable 'experimentalDecorators' in the jsconfig.json, but this didn't have any effect.

decorators

@egamma
Copy link
Member Author

egamma commented Feb 3, 2016

@billti This project is actually an interesting test case for Salsa, it uses webpack, bable, react, ES7 decorators, ES7 spread operator, and many other technologies (it is the one from the crash bug microsoft/vscode#2054)

To use it as a test case:

@billti
Copy link
Member

billti commented Feb 3, 2016

Looks like we explicitly check for and error on decorators in a JavaScript file (at https://github.com/Microsoft/TypeScript/blob/master/src/compiler/program.ts#L1171 ). Not sure why. I'll get this removed and experiment with the project provided a little also. Thanks!

@egamma
Copy link
Member Author

egamma commented Feb 17, 2016

@billti thank you!

@JakeGinnivan
Copy link

@billti @egamma you mentioned spread operator. Is there any way to get salsa to recognise that syntax and not give me errors?

@billti
Copy link
Member

billti commented Feb 25, 2016

@JakeGinnivan It's a much requested feature and on the radar, but not support yet. It's covered by #2103 (and please don't add more +1s to it... we have enough, we know you guys want it 😉 ).

@mikekidder
Copy link

-- Update 🎱 says my issue is this -- #7076, so you can ignore below -- 👍

Sorry to piggyback on the Issue, but on testing latest version of VSCode/Typescript/Salsa: Does a project require a jsconfig.json for it to recognize import { someExport } from 'whatever'; in your JS files?

If not, still getting Parsing error: The keyword 'import' is reserved (null) message. I can open separate issue.

@egamma
Copy link
Member Author

egamma commented Feb 27, 2016

@mikekidder

If not, still getting Parsing error: The keyword 'import' is reserved (null) message. I can open separate issue.

I think you have eslint enabled and this error message comes from eslint. To enable imports in eslint you need to enable sourcetype: module in the .eslintrc.json, pls see this gist for an example: https://gist.github.com/egamma/65c0e2a832393e3b625a

@mikekidder
Copy link

@egamma Thanks!. This project didn't have an .eslintrc.* file. Keep forgetting that plugin extension sets eslint.enable = true in VSCode User Settings.

Going to do workaround mentioned in microsoft/vscode-eslint#26, and just enable at Workspace Settings when I do want it.

Perhaps we need labeled helper tags that show the message origin, Ext: ESLint, Typescript, VSCode, etc.

@egamma
Copy link
Member Author

egamma commented Feb 28, 2016

Perhaps we need labeled helper tags that show the message origin, Ext: ESLint, Typescript, VSCode

Support for this is in place, see microsoft/vscode-eslint#22.

@waderyan
Copy link

I'm still seeing this issue in a later version of TypeScript

Error message on hover: 'decorators' can only be used in a .ts file.

image

tsc -v
Version 1.9.0-dev.20160130

Could it have been reintroduced in 1.9?

@billti
Copy link
Member

billti commented Feb 29, 2016

@waderyan Looks like you are using the Sublime plugin - is that right? We've not yet released the update to that containing 1.8, but it is pending (see microsoft/TypeScript-Sublime-Plugin#446 (comment) ). Unless you are pointing to a custom TypeScript build in the plugin, you are not yet on 1.8.

@waderyan
Copy link

I'm actually using VS Code Alpha build which uses the latest version of Salsa if I understand correctly.

@billti
Copy link
Member

billti commented Feb 29, 2016

Did you follow the steps at https://code.visualstudio.com/Updates to enable Salsa (i.e. do you see the Salsa indicator in the status bar as shown)?

@waderyan
Copy link

I'm on the latest Alpha build of VS Code which enables Salsa by default. I have confirmed that Salsa is enabled.

@billti
Copy link
Member

billti commented Feb 29, 2016

I just installed the latest Alpha build on my desktop (didn't have VSCode installed previously), and got the expected warning as shown below.

decorators

When I set the compiler option as indicated, the warning went away.

{
    "compilerOptions": {
        "experimentalDecorators": true
    }
}

Not sure what is up with your install of VSCode, but it seems to be working as expected.

@waderyan
Copy link

Excellent. Do you have a link to the list of compiler options? I was not aware of that option.

@billti
Copy link
Member

billti commented Feb 29, 2016

See https://github.com/Microsoft/TypeScript/wiki/tsconfig.json for the general file contents (jsconfig.json is the same). There is a link on that page to the full list of compilerOptions also.

@EisenbergEffect
Copy link

I've got the same issue. Even with a jsconfig.json with the above settings, decorators are detected as errors. VSCode autoupdated last week.

@pflannery
Copy link

I saw this issue a little while ago but seems to be working for me now. thanks

jsconfig

{
  "compilerOptions": {
    "experimentalDecorators": true
  }
}

image

tsc -v
Version 1.8.7

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

7 participants