Index a popular Typescript repository


This tutorial shows you how to add LSIF data for a TypeScript repository on your Sourcegraph instance to get precise code intelligence results.

Every time you add a repository to your Sourcegraph instance you automatically get fuzzy code intelligence results out of the box:

This can, in most cases, be good enough. But you may want to get precise results! By adding LSIF data for your repository you’ll be able to get precise results like shown below:


We recommend that use the latest version of Sourcegraph and that you have a basic understanding of how code intelligence works. See the following documents for more information:

  1. "Sourcegraph quickstart"
  2. "Introduction to code intelligence"

For the purposes of the tutorial we’ll be using the following repository: Before starting the tutorial, you should first "Add the repo to Sourcegraph".

Clone the TypeScript repository locally

Clone the TypeScript repository by running:

git clone

Install Sourcegraph CLI

Install the Sourcegraph CLI with

  • Linux:

    curl -L -o /usr/local/bin/src
    chmod +x /usr/local/bin/src
  • macOS:

    curl -L -o /usr/local/bin/src
    chmod +x /usr/local/bin/src


    brew install sourcegraph/src-cli/src-cli

Install the lsif-node indexer

Install the indexer by running:

npm install -g @sourcegraph/lsif-tsc

Run the indexer in the repo

  1. Navigate to the repo’s root folder (where the package.json/tsconfig.json is) and run lsif-tsc -p .

  2. A dump.lsif file should have been generated. This is file you are going to upload to your Sourcegraph instance.

Upload the LSIF data file to your Sourcegraph instance

  1. Go back to your terminal and make sure you are at the repo’s root folder (where the dump.lsif file is). Run the following command:

    src -endpoint=<your sourcegraph endpoint> lsif upload
  2. If you open the processing status URL, you will see the current status of your upload. Wait for it to complete.


You’ve indexed your first TypeScript repo! You can now go to any TypeScript file in that repo and get precise code intelligence results.

To learn what else you can do with Code Intelligence, see "Code intelligence".