Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Diagnostics are different from those produced by calling tsc directly #621

Open
wincent opened this issue Jul 21, 2019 · 2 comments
Open

Comments

@wincent
Copy link

wincent commented Jul 21, 2019

In this project I see some puzzling differences between the diagnostics reported by:

  • javascript-typescript-langserver (2.11.3) + LanguageClient-neovim (56859896904347856) + Neovim (v0.4.0-dev) + typescript (3.5.3)
  • and tsc (from typescript 3.5.3)

tsc will report a clean build, but javascript-typescript-langserver complains in this file that Argument of type 'Iterable<T> | null | undefined' is not assignable to parameter of type 'ReadonlyArray<T> | null....

There are two SetConstructor overloads:

Evidently, tsc alone is picking the former, but in the context of javascript-typescript-langserver, it's picking the latter, leading to the diagnostic.

If I turn debug logging on in LanguageClient-neovim, I get this.

And logging with --trace --logfil some-file to javascript-typescript-stdio I get this.

I don't know if this is related to #618 — perhaps it is not picking up my tsconfig.json. But I don't know if this is a bug in my own code, in TypeScript, in javascript-typescript-langserver, in LanguageClient-neovim, or maybe something else I am overlooking. One thing I did notice was that when I tried to repro in VSCode, it had the same problem, but when I updated it, the problem resolved; the release notes said:

JavaScript and TypeScript nightly extension

The new JavaScript and TypeScript nightly extension uses the nightly build of TypeScript (typescript@next) for VS Code's built-in TypeScript version, which powers JavaScript and TypeScript IntelliSense. This makes it easy to test the latest TypeScript features and provide feedback about them!"

@wincent
Copy link
Author

wincent commented Jul 21, 2019

When I directly interact with tsserver it agrees with tsc that there are no errors:

$ tsserver
Content-Length: 76

{"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":91220}}
{"seq":1,"type":"quickinfo","command":"open","arguments":{"file":"/Users/glh/code/corpus/src/renderer/util/FrozenSet.ts"}}
Content-Length: 231

{"seq":0,"type":"event","event":"projectLoadingStart","body":{"projectName":"/Users/glh/code/corpus/tsconfig.json","reason":"Creating possible configured project for /Users/glh/code/corpus/src/renderer/util/FrozenSet.ts to open"}}
Content-Length: 118

{"seq":0,"type":"event","event":"projectLoadingFinish","body":{"projectName":"/Users/glh/code/corpus/tsconfig.json"}}
Content-Length: 717

{"seq":0,"type":"event","event":"telemetry","body":{"telemetryEventName":"projectInfo","payload":{"projectId":"689c12ab1bb1c95839aea14bce157cb3832179faeccd444e614b260d104bf81f","fileStats":{"js":0,"jsSize":0,"jsx":0,"jsxSize":0,"ts":5,"tsSize":7088,"tsx":12,"tsxSize":12539,"dts":99,"dtsSize":3906414,"deferred":0,"deferredSize":0},"compilerOptions":{"jsx":"react","module":"commonjs","moduleResolution":"node","outDir":"","strict":true,"target":"es2017"},"typeAcquisition":{"enable":false,"include":false,"exclude":false},"extends":false,"files":false,"include":true,"exclude":false,"compileOnSave":false,"configFileName":"tsconfig.json","projectType":"configured","languageServiceEnabled":true,"version":"3.5.3"}}}
Content-Length: 198

{"seq":0,"type":"event","event":"configFileDiag","body":{"triggerFile":"/Users/glh/code/corpus/src/renderer/util/FrozenSet.ts","configFile":"/Users/glh/code/corpus/tsconfig.json","diagnostics":[]}}
{"seq":2,"type":"request","command":"semanticDiagnosticsSync","arguments":{"file":"/Users/glh/code/corpus/src/renderer/util/FrozenSet.ts"}}
Content-Length: 105

{"seq":0,"type":"response","command":"semanticDiagnosticsSync","request_seq":2,"success":true,"body":[]}
^C
zsh: interrupt  tsserver

But looking at the process hierarchy, I see that javascript-typescript-stdio isn't actually interacting with tsserver in any obvious way, but by some other mechanism...

-+= 00001 root /sbin/launchd
 \-+= 70559 glh tmux new-session -d -s dot -n vim -x 179 -y 52
   \-+= 87237 glh -zsh
     \-+= 87678 glh zsh
       \-+= 90449 glh nvim src/renderer/util/FrozenSet.ts
         |-+= 90451 glh /Users/glh/code/wincent/roles/dotfiles/files/.vim/pack/bundle/opt/LanguageClient-neovim/bin/languageclient
         | \--- 90452 glh node /Users/glh/n/bin/javascript-typescript-stdio
         \--= 90454 glh /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python -c import sys; sys.path.remove(""); import neovim; neovim.start_host() /Users/glh/code/wincent/roles/dotfiles/files/.vim/pack/bundle/opt/deoplete/rplugin/python3/deoplete

@wincent
Copy link
Author

wincent commented Jul 21, 2019

One final data point. If I swap out javascript-typescript-langserver for https://www.npmjs.com/package/typescript-language-server, then diagnostics agree with tsc/tsserver, as you'd expect, because I see it is using tsserver:

-+= 00001 root /sbin/launchd
 \-+= 70559 glh tmux new-session -d -s dot -n vim -x 179 -y 52
   \-+= 87237 glh -zsh
     \-+= 87678 glh zsh
       \-+= 91686 glh nvim src/renderer/util/FrozenSet.ts
         |-+= 91688 glh /Users/glh/code/wincent/roles/dotfiles/files/.vim/pack/bundle/opt/LanguageClient-neovim/bin/languageclient
         | \-+- 91689 glh node /Users/glh/n/bin/typescript-language-server --stdio
         |   \-+- 91691 glh node /Users/glh/code/corpus/node_modules/.bin/tsserver --cancellationPipeName /private/var/folders/tl/04jnvr4s34v704k5h2rqjmkh0000gn/T/7a8e12d526fe037a004e10233a71becc/tscancellation*
         |     \--- 91692 glh /Users/glh/n/bin/node /Users/glh/code/corpus/node_modules/typescript/lib/typingsInstaller.js --globalTypingsCacheLocation /Users/glh/Library/Caches/typescript/3.5 --typesMapLocation /Users/glh/code/corpus/node_modules/typescript/lib/typesMap.json
         |--= 91694 glh /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python -c import sys; sys.path.remove(""); import neovim; neovim.start_host() script_host.py
         \--= 91698 glh /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python -c import sys; sys.path.remove(""); import neovim; neovim.start_host() /Users/glh/code/wincent/roles/dotfiles/files/.vim/pack/bundle/opt/deoplete/rplugin/python3/deoplete

wincent added a commit to wincent/wincent that referenced this issue Jul 21, 2019
Because I am having problems with the diagnostics it shows in Vim not
agreeing with what I get from `tsc` or `tsserver` on the command-line,
as described here:

sourcegraph/javascript-typescript-langserver#621

The confusing naming here drives me crazy, but what is happening in this
commit is moving from:

- NPM package: javascript-typescript-langserver v2.11.3
- Executable: `javascript-typescript-stdio`
  (related variant of `javascript-typescript-langserver`, also included
  with the package)
- Package page: https://www.npmjs.com/package/javascript-typescript-langserver
  (1,171 weekly downloads)
- GitHub page: https://github.com/sourcegraph/javascript-typescript-langserver
  (596 stars)

to:

- NPM package: typescript-language-server v0.3.8
- Executable: `typescript-language-server --stdio`
- Package page: https://www.npmjs.com/package/typescript-language-server
  (4,175 weekly downloads)
- GitHub page: https://github.com/theia-ide/typescript-language-server
  (166 stars)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant