amatiasq / vsc-sort-imports

Sort ES6 imports automatically.
ISC License
60 stars 22 forks source link

Error sorting imports: SyntaxError: Unexpected token, expected; (1:8) #13

Closed strongui closed 6 years ago

strongui commented 6 years ago

My line one is this:

declare const jQuery: JQuery;

This is in a typescript file.

amatiasq commented 6 years ago

Do you have any settings in your VS Code configuration or in the package.json?

strongui commented 6 years ago

@amatiasq No to both. Do I need to put something to get rid of the error?

amatiasq commented 6 years ago

No, in theory if you have no specific configuration it should load the typescript parser.

You can try to manually set the parser to typescript in your package.json, here you have an example.

I guess your extension is .ts, right?

strongui commented 6 years ago

@amatiasq yes my files have .ts extension.

I added this to my package.json

"importSort": {
  ".js, .jsx, .es6, .es": {
    "parser": "babylon",
    "style": "eslint"
  },
  ".ts, .tsx": {
    "parser": "typescript",
    "style": "eslint"
  }
}

Then I restarted VS Code and now it works. Thanks. Maybe it's just some VS Code weirdness? Anyway, ticket can be closed as far as I'm concerned.

amatiasq commented 6 years ago

This is weird, it should work out of the box. All you did was to copy what is supposed to be the default configuration. I'll take a deeper look into that.

I'm happy you found a work around for now. Thanks for the report!

strongui commented 6 years ago

@amatiasq well your fix worked for me :) that you for the quick response! Love the plugin! Not sure, if I can send you any log files if you want? Let me know if I can help.

amatiasq commented 6 years ago

Closed by mistake

amatiasq commented 6 years ago

Closed due to lack of activity