| 📦 Turbo JS 91999d1 k33g 17h ago | 1 | # How to ask what the code means |
| 2 | |
| 3 | This guide shows how to follow a name through a JavaScript project: what it is, where it is declared, and what is wrong with it. It assumes Turbo JS is installed and the language server is running — the status bar says `LSP: ready` when it is. |
| 4 | |
| 5 | For moving around a file — searching, jumping to a line, switching windows — see [How to move around a file](navigate-code.md) instead. |
| 6 | |
| 7 | ## Put the cursor on a name |
| 8 | |
| 9 | Any character of it will do. Every question below asks about the **position of the cursor**, not about a selection, so there is nothing to highlight first. |
| 10 | |
| 11 | ## Ask |
| 12 | |
| 13 | | To find | Do | Shortcut | |
| 14 | | --- | --- | --- | |
| 15 | | What it is | **Code ▸ Describe symbol** | `F1` | |
| 16 | | Where it is declared | **Code ▸ Go to definition** | `F12` | |
| 17 | | Where its *type* is declared | **Code ▸ Go to type definition** | | |
| 18 | | What implements it | **Code ▸ Find implementations…** | | |
| 19 | | Everywhere it is used | **Code ▸ Find references…** | `Shift-F12` | |
| 20 | |
| 21 | `typescript-language-server` answers all five for plain JavaScript. **Describe symbol** shows a declaration's signature and the JSDoc comment written immediately above it; **Go to type definition** on `const shape = new Circle()` goes to `class Circle`; **Find implementations…** on a class lists its subclasses; **Find references…** lists the declaration and every call. |
| 22 | |
| 23 | One answer takes you straight there. Several open a list showing each file, its line, and the text of that line; move with the arrow keys, `Enter` to go, `Esc` to stay where you are. |
| 24 | |
| 25 | ## When nothing comes back |
| 26 | |
| 27 | Three different things look alike, and the status bar tells them apart: |
| 28 | |
| 29 | | It says | Meaning | |
| 30 | | --- | --- | |
| 31 | | `No … found`, in the question's own words | The server answered, and there are none | |
| 32 | | `LSP: starting…` | The server has not finished starting. Wait a moment and ask again. | |
| 33 | | `LSP: off` on the status bar | No server is running. See [How to enable completion](enable-completion.md). | |
| 34 | | `LSP: no typescript-language-server — npm install -g typescript-language-server typescript@6` | There is no `typescript-language-server` on `PATH`, nor in the directories nvm, npm, pnpm and Volta install into. See [How to enable completion](enable-completion.md). | |
| 35 | |
| 36 | ## Find something by name instead |
| 37 | |
| 38 | - **Code ▸ Symbol in file…** lists what the file in front declares, indented, with each symbol's kind — the functions and the classes. An outline you can walk; choosing one goes to it. |
| 39 | - **Code ▸ Symbol in project…** (`Ctrl-T`) asks for a name and searches the whole project. |
| 40 | |
| 41 | ## See what is wrong |
| 42 | |
| 43 | **Code ▸ Problems…** lists every problem the server has reported, for **every file it has loaded** — usually more than the one you are editing. Choosing one goes to the line. |
| 44 | |
| 45 | `typescript-language-server` reports **syntax errors** in a plain `.js` file, on open and again on every edit: a `function main( {` gets a `×` in the gutter and a `⚠` message on the status bar. A type mistake gets no mark unless you ask for checking — put `// @ts-check` on the first line of the file, or `checkJs` in a `jsconfig.json` — and then type errors arrive the same way. |
| 46 | |
| 47 | Lines with a problem carry a mark in the gutter, beside the line number: |
| 48 | |
| 49 | | Mark | Meaning | |
| 50 | | --- | --- | |
| 51 | | `×` | An error | |
| 52 | | `!` | A warning | |
| 53 | | `i` | Information | |
| 54 | | `·` | A hint | |
| 55 | |
| 56 | A line with more than one problem shows the worst of them. |
| 57 | |
| 58 | **The marks need the line numbers.** They sit in the column that separates the numbers from the text, so hiding the gutter with **Options ▸ Line numbers** hides them too. |
| 59 | |
| 60 | ## See also |
| 61 | |
| 62 | - Every item and its key: [Menus](../reference/menus.md) |
| 63 | - Getting a server running: [How to enable completion](enable-completion.md) |
| 64 | - What the editor asks, and why: [Colouring and completion](../explanation/colouring-and-completion.md) |
| 65 | - What `typescript-language-server` answers, exactly: [JavaScript tools](../reference/javascript-tools.md) |