xsburg / vscode-javascript-booster

Sprinkle extra refactorings, code actions and commands over your JavaScript! 🍩 TypeScript and Flow are first class citizens as well!
https://marketplace.visualstudio.com/items?itemName=sburg.vscode-javascript-booster
159 stars 13 forks source link

Typescript support (nothing happens on alt+enter) #18

Closed maricn closed 5 years ago

maricn commented 5 years ago

OK, I'm editing my old question (below), since I realized I'm trying it with typescript and that's why it's not working.

Do you have any plans to support typescript?

With all the default settings, it loads some actions when I run

JS Booster: Reload Code Actions and outputs to console stuff like this:

2019-06-19T08:19:08.969Z: 22 code actions loaded.
2019-06-19T08:19:57.673Z: 22 code actions loaded.
2019-06-19T08:20:00.191Z: 22 code actions loaded.
2019-06-19T08:29:40.198Z: Syntax error in file file:///Users/nikola/Workspace/CoreV2/src/email/email.service.ts (29:0).
2019-06-19T08:29:42.331Z: 22 code actions loaded.
2019-06-19T08:29:43.810Z: 22 code actions loaded.
2019-06-19T08:55:09.039Z: Syntax error in file file:///Users/nikola/Workspace/CoreV2/src/users/cleanup.service.ts (6:0).
2019-06-19T08:55:11.844Z: 22 code actions loaded.
2019-06-19T08:55:21.646Z: 22 code actions loaded.

However, when I click alt+enter (option+enter) it doesn't display anything. I'm trying it on ternary operators and if-else blocks - there's no popup icon, and code actions shows No code actions available.

I'm running VSCodium Version 1.35.1 (1.35.1) and I've tried it on normal Microsoft Code Version 1.35.1 (1.35.1) with same result. I'm on macOS Mojave Version 10.14.5 (18F132) Darwin Kernel Version 18.6.0.

xsburg commented 5 years ago

Hi @maricn,

Actually, the extension works well with TypeScript and there should not be any problems.

Can you create a new file with the following fragment so that we check that the primitive case works well? Don't forget to check that the language of the file is TypeScript or TypeScript React (shown in the bottom right corner).

function doFoo(foo: string) {
    if (foo) {
        return false;
    }
    return foo;
}

I also see some syntax errors in the log that you've attached. Please note that code actions only work when the file you are editing has no syntax errors. If there are none, please attach the code snippet of your code, maybe the extension`s parser fails where it shouldn't.

Cheers!

maricn commented 5 years ago

Hm.. I tried it javascript files and it works. On the basic example that you provided, it also works. So I guess, there is some other problem.

I think I narrowed it down to syntax errors in my service classes (I'm using NestJS with typescript). It's always reporting syntax errors on export class ClassName { line where such class was decorated with @Injectable() (coming from @nestjs/common).

import { Injectable } from '@nestjs/common';
@Injectable()
export class EmailService {
}

After a bit of poking around, it might be related to the fact typescript decorators are an experimental feature. I have them enabled in my project's tsconfig but your extension always reports those lines as having syntax errors. Interestingly, it happens for class and method decorators, but not for property decorators. 🤔

xsburg commented 5 years ago

Thank you for looking into it @maricn!

I've just checked and decorators are indeed not supported by the version of Babel that this extension uses.

I'm now privately testing a new version of the extension with an updated @babel/parser and some other new features. The latest version works with decorators well, so as soon as I finish testing and publish a new release the problem will go away.

Cheers!

maricn commented 5 years ago

Thank you for quick response. Much appreciated! 🖖

xsburg commented 5 years ago

Closing the issue as v0.11.0 is now released.