tsc are installed and in your PATH. There are detailed instructions below. (
tsc -v should be at least
4.2.4.) Get the typescript code for the jsonrpc protocol with
git clone firstname.lastname@example.org:microsoft vscode-languageserver-node.git or
git clone https://github.com/microsoft/vscode-languageserver-node.git
util.ts expects it to be in your HOME directory
If you want to reproduce the existing files you need to be on a branch with the same git hash that
util.ts expects, for instance,
git checkout 7b90c29
Code is generated and normalized by
tsc && node code.js && gofmt -w ts*.go
util.ts.) This generates 3 files in the current directory,
tsprotocol.go containing type definitions, and
tsclient.go containing API stubs.
util.tsuse the Typescript compiler's API, which is introduced in their wiki.
util.tsare filled with heuristics and special cases. Therefore they are tied to a specific commit of
vscode-languageserver-node. The hash code of the commit is included in the header of the generated files and stored in the variable
go.ts. It is checked (see
util.ts) on every execution.
ts*.gofiles is only semi-automated. Please file an issue if the released version is too far behind.
gitHashby hand (
git()shows how to find the hash).
code.ts. This will likely fail because the heuristics don't cover some new case. For instance, some simple type like
stringmight have changed to a union type
string | [number,number]. Another example is that some generated formal parameter may have anonymous structure type, which is essentially unusable.
internal/lsp/protocoland try to build
goplsand its tests. This will likely fail because types have changed. Generally the fixes are fairly easy. Then run all the tests.
(The instructions are somewhat different for Linux and MacOS. They install some things locally, so
$PATH needs to be changed.)
sudo apt update(if you can't
sudothen these instructions are not helpful)
sudo apt install nodejs(this may install
/usr/bin/node. For me,
/usr/bin/nodejspointed to an actual executable
/etc/alternatives/nodejs, which should be copied to
sudo apt intall npm
bindirectory in your path, perhaps?)
sudo npm install -g npmis the command.)
npm -vshould produce version numbers.
npm install typescript
tscwill be in
node_modules/.bin, so put that directory in your path.
tsc -vshould print “Version 4.2.4” (or later). If not you may (as I did) have an obsolete tsc earlier in your path.
npm install @types/node(Without this there will be many incomprehensible typescript error messages.)