srclib-typescript is a srclib toolchain that performs TypeScript code analysis: type inference, documentation generation, jump-to-definition, dependency resolution, etc. It enables this functionality in any client application whose code analysis is powered by srclib, including Sourcegraph.
This toolchain is not a standalone program; it provides additional functionality
to applications that use srclib.
First,
install the srclib program (see srclib installation instructions).
Then run:
git clone https://github.com/sourcegraph/srclib-typescript.git
cd srclib-typescript
srclib toolchain install typescript
To verify that installation succeeded, run:
srclib toolchain list
You should see this srclib-typescript toolchain in the list. Now that this toolchain is installed, any program that relies on srclib will support TypeScript. (TODO(sqs): add a tutorial link)
-
Support only for projects which have tsconfig.json file in the root directory, other package systems are not supported.
-
To be fully analysed file need to be included in the Files section of tsconfig.json file or to be referenced via reference path.
-
Production of more than one ref for reference is currently switched off if multiple declarations are provided by AST tree. Reasons - src tool produces bugs in this case, for some references AST tree gives just the same declarations and it leads to duplicate ref error. Need to go back to this issue after a while.
srclib-typescript is alpha-quality software. It powers code analysis on Sourcegraph.com and additionally has been tested on the next typescript repositories:
Successfully:
- n3-charts/line-chart
- palantir/plottable
- SierraSoftworks/Iridium
- valor-software/ng2-bootstrap
- DefinitelyTyped/tsd
- Microsoft/code-push
- Microsoft/TypeScriptSamples
- mgechev/angular2-seed
- Microsoft/vscode-go
- ng-book/angular2-rxjs-chat
- auth0/angular2-authentication-sample
- NativeScript/nativescript-cli
- uProxy/uproxy
- rogerpadilla/angular2-minimalist-starter
- rangle/batarangle
- VSCodeVim/Vim
- ngUpgraders/ng-forward
- vega/vega-lite
Testing in progress:
Next issues were found:
- Unsupported builtins for interfaces.
- Partially supported shorthand property assignments.
- ExportSpecifiers can work better.
- Import clause is not fully supported (syntax tree kind = 226, reproduced on doppio project).
Testing this toolchain requires that you have installed srclib from
srclib and that you have this
toolchain set up. See srclib documentation for more information.
To test this toolchain's output against the expected output, run:
# run the tests
srclib test
Patches are welcomed via GitHub pull request! See CONTRIBUTING.md for more information. srclib-typescript's toolchain solution is based on Typescript AST compiler api.