microsoft / vscode-typescript-tslint-plugin

VS Code extension that provides TSLint support using the typescript-tslint-plugin
https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin
MIT License
188 stars 35 forks source link

Bug with a spread operator #85

Closed KostyaTretyak closed 5 years ago

KostyaTretyak commented 5 years ago

If you do the following:

git clone git@github.com:restify-ts/router.git
cd router
git checkout 11a929
yarn
npx tslint -p .

you can see the tslint errors:

ERROR: ./router/src/router.ts:52:20 - non-arrow functions are forbidden
ERROR: ./router/src/router.ts:53:15 - Shadowed name: 'handle'
ERROR: ./router/src/router.ts:59:20 - Identifier 'key' is never reassigned; use 'const' instead of 'let'.

then open src/router.ts in VS Code and you can see that the vscode-typescript-tslint-plugin not work.

I think the bug is related to the spread operator. If we comment out 37 line, the plugin works as expected:

  all(...arg) {
    httpMethods.forEach(method => {
      // this.on(method, ...arg);
    });
    return this;
  }
mjbvz commented 5 years ago

Seems to be working for me:

Screen Shot 2019-05-01 at 10 45 11 AM

What VS Code version and OS are you on?

KostyaTretyak commented 5 years ago

VS Code 1.33.1, Ubuntu 16.04 (OS: Linux x64 4.15.0-48-generic)

KostyaTretyak commented 5 years ago

Maybe you did not do git checkout 11a929 before?

mjbvz commented 5 years ago

I'm on that commit. Are the implicitAny errors and other non-tslint errors expected?

mjbvz commented 5 years ago

You can also check the TS Server log:

  1. Set "typescript.tsserver.log": "verbose",
  2. Restart VS Code and reproduce the problem
  3. In VS Code, run the TypeScript: Open TS Server log command
  4. This should open a folder with a tsserver.log file in it

Look through that log file for lines that mention tslint, such as Info 224 [10:46:52.902] [typescript-tslint-plugin] "Computing tslint semantic diagnostics for '/Users/matb/projects/san/router/src/node.ts'"

If you can share the log, I can see if it shows something odd going on

KostyaTretyak commented 5 years ago

My log file: tsserver.log

In tsconfig.json: "compilerOptions": { "noImplicitAny": true }

mjbvz commented 5 years ago

It looks like something going wrong with your copy of typescript, see the line:

Err 104   [21:11:10.146] Exception on executing command delayed processing of request 17:

    Debug Failure. False expression.

    Error: Debug Failure. False expression.
        at Object.first (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:1097:15)
        at getArgumentArityError (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:50167:32)
        at resolveCall (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:50307:41)
        at resolveCallExpression (/usr/share/code/resources/app/extensions/node_modules/typescript/lib/tsserver.js:50593:20)
        at resolveSignature
...

If you disable this extension, do you get any errors in this project?

Also, can you please test this using typescript@next by following these instructions. https://github.com/Microsoft/TypeScript/issues/30591 suggest this debug failure should be fixed in @next

KostyaTretyak commented 5 years ago

With typescript@3.4.5 the problem has disappeared. @mjbvz, thanks for the help!