iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

IntelliSense

How VS Code IntelliSense actually works and how to make it work harder for you: tsserver, language servers, JSDoc cues, and snippets.

VS Code — IntelliSense deep dive

EXAMPLE
# ===== Where suggestions come from =====
# 1. Language servers (LSP): tsserver for TS/JS, gopls for Go, pyright for Python, etc.
# 2. Word-based suggestions: tokens from open buffers (fallback)
# 3. Snippet engines: user, workspace, extension snippets
# 4. Path / file completions
# 5. AI assistants (Copilot, Cursor) wrapping the above

# ===== Anatomy of a completion =====
# label, detail, documentation, insertText, kind, sortText
# kind drives the icon; sortText controls ordering

# ===== TypeScript: turn on the strictness you want =====
# tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "verbatimModuleSyntax": true,
    "isolatedModules": true,
    "resolveJsonModule": true,
    "types": ["node"]
  }
}
# IntelliSense quality scales with the strictness of your config.

# ===== Plain JS gets typed by JSDoc =====
/**
 * @param {{ id: string, total: number }} order
 * @returns {Promise<{ id: string, status: 'queued' | 'sent' }>}
 */
async function ship(order) { /* ... */ }
# Now JS files get autocomplete on the order param and the returned shape.

# ===== Trigger Suggest on demand =====
# Ctrl+Space  - manual trigger
# Ctrl+.      - quick fix / code actions (auto-import, add missing prop)
# F12         - go to definition
# Alt+F12     - peek
# Ctrl+T      - workspace symbols
# Ctrl+Shift+. (codeAction)  - rename, extract, organise imports

# ===== Snippets =====
# .vscode/test.code-snippets
{
  "Vitest test": {
    "scope": "typescript,javascript",
    "prefix": "vit",
    "body": [
      "import { describe, it, expect } from 'vitest';",
      "",
      "describe('${1:thing}', () => {",
      "  it('${2:does the thing}', () => {",
      "    $0",
      "  });",
      "});"
    ]
  }
}
# Tab stops with ${1:placeholder}, final cursor at $0.

# ===== Tame noisy completions =====
# settings.json
{
  "editor.suggest.localityBonus": true,
  "editor.acceptSuggestionOnEnter": "smart",
  "editor.suggest.preview": true,
  "editor.parameterHints.enabled": true,
  "editor.inlineSuggest.enabled": true,
  "typescript.preferences.importModuleSpecifier": "non-relative",
  "typescript.updateImportsOnFileMove.enabled": "always"
}

# ===== Diagnostics: when IntelliSense feels wrong =====
# - 'TypeScript: Restart TS Server'           - palette command after big refactors
# - Output panel -> 'TypeScript' channel      - shows tsserver errors
# - Check tsconfig 'include' / 'exclude'      - file may not be in the project
# - Multi-root workspaces: each root has its own tsserver

# ===== Patterns to internalise =====
# - Strict TS = better IntelliSense; relax only where you must
# - JSDoc in JS files is a budget version of TypeScript
# - Workspace snippets > user snippets for team conventions
# - Use auto-import organisation on save: 'editor.codeActionsOnSave'

# ===== Pitfalls =====
# - 'tsserver is slow' is usually 'tsconfig include is too broad'
# - Disabling strictness one-by-one until red squiggles disappear (mask real bugs)
# - Mixing CommonJS and ESM without isolatedModules -> wrong-completions
# - Open files outside the workspace fall back to word completion only

Why it matters

IntelliSense is the productivity multiplier that hides in plain sight. Strict tsconfig, JSDoc in JS, workspace snippets, and a clean tsserver state: spend 30 minutes wiring it up and reap the seconds back on every keystroke for years.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
// IntelliSense: completions + hover docs + parameter hints.
// Triggered by typing or Ctrl + Space.
// Powered by the language server (TS, Pyright, gopls, rust-analyzer, …).
Try it Yourself »

Discussion

Loading…