TS services commandline server (for editor/IDE plugins)

Topics: General
Nov 30, 2012 at 3:06 PM
Edited Nov 30, 2012 at 3:07 PM

The typescript-tools repo has an experimental server (tss) that provides access to TS language services from the commandline (currently: type lookup, jump to definition, completion). The protocol is simple enough to be useable from most programmable editors/IDEs: commands in, JSON info out.

The repo includes a Vim plugin, so us Vim users can directly start to go through the TS sources, but I hope that users of other editors/IDEs will find tss useful for extending their tools. You can either communicate with tss as an asynchronous subprocess (as I do for the Vim plugin), or you can look through the code to get some ideas (and tell me if I do anything wrong!-).

related threads: 

http://typescript.codeplex.com/discussions/404060
http://typescript.codeplex.com/discussions/397821

Dec 1, 2012 at 8:28 AM

Calling typescript-tools from emacs seems to work fine.

 

But I found a few issues.
1. After call 'reload', I get interal error.

> info 306 4 C:/cygwin/home/zakki/ts/typescript-tools/tss.ts

> {"pos":9500,"linecol":[306,4],"symbol":"tss: TSS","type":"() => ...

> reload

> "reloaded C:/cygwin/home/zakki/ts/typescript-tools/tss.ts, TSS listening.."

> info 306 4 C:/cygwin/home/zakki/ts/typescript-tools/tss.ts

> "TSS command processing error: Error: Interal error: No AST found for file "C:/cygwin/home/zakki/ts/typescript-tools/tss.ts"."

2. "info" command just after function call fails.

> $ cat test.ts> encodeURI("a").

> $ node tss.js test.ts

> info 1 16 C:/cygwin/home/zakki/ts/typescript-tools/test.ts

> "TSS command processing error: TypeError: Cannot read property 'minChar' of null"

Dec 1, 2012 at 9:23 AM

Calling typescript-tools from emacs seems to work fine.

That is good to hear!-)

But I found a few issues.

1. After call 'reload', I get interal error.

Yes, 'reload' is currently completely broken. There is some global state that I haven't been able to find and reset yet. Help welcome!

This is issue no 1 on the TODO list - currently, one needs to end&restart the server, which is annoying, or use 'update', which doesn't cover the same use case.

2. "info" command just after function call fails.

> "TSS command processing error: TypeError: Cannot read property 'minChar' of null"

Thanks for the test case. There was an unguarded property access in 'info' - should now be fixed.

Btw, I rarely use 'info', other than for debugging/development, as it seems easier to get just the specific info I need from the individual commands. So, 'info' is more likely to be broken occasionally. In this case, 'info' has some extra code to determine whether completion is for members or non-members, which isn't yet in 'completions'.

Dec 1, 2012 at 2:13 PM
clausreinke wrote:

1. After call 'reload', I get interal error.

Yes, 'reload' is currently completely broken. There is some global state that I haven't been able to find and reset yet.

Found and fixed.