CSpell TypeScript Dictionary
@cspell/dict-typescript (current stable version 3.2.3) provides a specialized dictionary for spell-checking TypeScript and JavaScript-specific terms, keywords, and common libraries within projects using the `cspell` spell checker. As part of the larger `cspell-dicts` monorepo, it receives updates as new programming terms emerge, often aligned with the monorepo's generally frequent release cadence. This dictionary is crucial for developers seeking to reduce false positives and improve the accuracy of spell checks in JavaScript and TypeScript codebases, differentiating it from general English dictionaries by its focus on programming-specific vocabulary like "camelCase", "enum", "typedef", "ESM", and framework-specific terms. It acts as an extension to `cspell`, enhancing its ability to understand code context, helping maintain consistency and reduce errors in technical documentation and code comments.
Common errors
-
Error: Dictionary 'typescript' not found.
cause The `@cspell/dict-typescript` package is not installed, or `cspell` cannot locate it based on your configuration or global link setup.fixEnsure the package is installed: `npm install @cspell/dict-typescript` (local) or `npm install -g @cspell/dict-typescript && cspell-dict-typescript-link` (global). Verify your `cspell.json` properly references `"dictionaries": ["typescript"]`. -
cspell-dict-typescript-link: command not found
cause The global linking command `cspell-dict-typescript-link` is not available in your system's PATH, usually because the package was not installed globally or the global binaries directory is not in your PATH.fixInstall the package globally: `npm install -g @cspell/dict-typescript`. If the problem persists, ensure your npm global binaries directory is correctly added to your system's PATH environment variable.
Warnings
- gotcha The package name in the npm registry is `@cspell/dict-typescript` (version 3.2.3), differing from the provided `cspell-dict-typescript` (version 1.1.5). Always use `@cspell/dict-typescript` for installation to get the latest and correct package.
- gotcha Newer versions of `cspell` (v6.x and above) often bundle many common dictionaries, including `typescript`. You might not need to install `@cspell/dict-typescript` explicitly if your `cspell` version already includes it, as this can lead to redundant dictionary loading or configuration conflicts.
- gotcha When configuring in `cspell.json` or similar files, you enable the dictionary by its short name `typescript` in the `dictionaries` array. Attempting to use the full package name (`@cspell/dict-typescript`) or a file path directly in this array will not work for dictionary loading.
Install
-
npm install cspell-dict-typescript -
yarn add cspell-dict-typescript -
pnpm add cspell-dict-typescript
Imports
- typescript
import { typescript } from '@cspell/dict-typescript';{ "dictionaries": ["typescript"] } - cspell-ext.json
require('@cspell/dict-typescript/cspell-ext.json');{ "import": ["<path to node_modules>/@cspell/dict-typescript/cspell-ext.json"] } - cspell-dict-typescript-link
import cspellDictTypescriptLink from 'cspell-dict-typescript/link';
npm install -g @cspell/dict-typescript cspell-dict-typescript-link
Quickstart
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"language": "en",
"dictionaries": [
"typescript" // Enable the TypeScript dictionary
],
"words": [],
"ignorePaths": [
"node_modules",
"dist",
"build",
"coverage"
]
}
// To use this, first install cspell and the dictionary:
// npm install -D cspell @cspell/dict-typescript
// Then run cspell:
// npx cspell "**/*.{ts,tsx,js,jsx}"