or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mddictionaries.mdindex.mdparser.mdreporter.md
tile.json

index.mddocs/

CSpell Types

CSpell Types is a comprehensive TypeScript types library that provides the foundational type definitions for the CSpell spell checking ecosystem. It serves as the core type library that enables type-safe configuration and development across all CSpell tools and libraries, offering zero runtime dependencies while providing complete type coverage for the spell checker's configuration schema.

Package Information

  • Package Name: @cspell/cspell-types
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @cspell/cspell-types

Core Imports

import type { CSpellUserSettings, CSpellSettings, Issue } from "@cspell/cspell-types";

For parser-specific types:

import type { Parser, ParsedText, ParseResult } from "@cspell/cspell-types/Parser";

CommonJS:

const { CSpellUserSettings } = require("@cspell/cspell-types");

Basic Usage

import type { CSpellUserSettings, DictionaryDefinition } from "@cspell/cspell-types";

// Define a basic CSpell configuration
const config: CSpellUserSettings = {
  version: "0.2",
  language: "en",
  words: ["TypeScript", "ESLint"],
  dictionaries: ["typescript", "node"],
  ignoreWords: ["lorem", "ipsum"]
};

// Define a custom dictionary
const customDict: DictionaryDefinition = {
  name: "my-dictionary",
  path: "./dictionaries/custom.txt",
  description: "Custom project dictionary"
};

// Configure language-specific settings
const advancedConfig: CSpellUserSettings = {
  version: "0.2",
  languageSettings: [
    {
      languageId: "typescript",
      dictionaries: ["typescript", "node"]
    }
  ],
  overrides: [
    {
      filename: "**/*.test.ts",
      enabled: false
    }
  ]
};

Architecture

CSpell Types is organized around several key type systems:

  • Configuration System: Core configuration types (CSpellSettings, CSpellUserSettings) for spell checker setup
  • Dictionary System: Dictionary definitions and management types for custom dictionaries and word lists
  • Reporter System: Issue reporting and progress tracking interfaces for spell check results
  • Parser System: Text parsing interfaces for different file types and content extraction
  • Feature System: Feature flags and experimental settings for advanced configurations

Capabilities

Configuration Types

Core configuration interfaces for setting up CSpell spell checking behavior, including basic settings, advanced options, and source tracking.

interface CSpellUserSettings extends CSpellSettings {}

interface CSpellSettings extends FileSettings, LegacySettings {
  readonly version?: Version;
}

interface FileSettings extends BaseSetting, ExtendableSettings {}

interface BaseSetting {
  enabled?: boolean;
  words?: string[];
  ignoreWords?: string[];
  dictionaries?: DictionaryReference[];
  languageSettings?: LanguageSetting[];
}

Configuration Types

Dictionary Management

Dictionary configuration types for managing built-in and custom dictionaries, including inline dictionaries and replacement mappings.

type DictionaryDefinition = 
  | DictionaryDefinitionPreferred
  | DictionaryDefinitionCustom
  | DictionaryDefinitionAugmented
  | DictionaryDefinitionInline;

interface DictionaryDefinitionPreferred extends DictionaryDefinitionBase {
  path: DictionaryPath;
}

interface DictionaryDefinitionCustom extends DictionaryDefinitionBase {
  path: CustomDictionaryPath;
  scope?: CustomDictionaryScope;
}

Dictionary Management

Reporter and Progress System

Interfaces for issue reporting, progress tracking, and spell check results with support for custom reporters and emitters.

interface CSpellReporter {
  issue: (issue: Issue) => void;
  info: MessageEmitter;
  debug: DebugEmitter;
  error: ErrorEmitter;
  progress: ProgressEmitter;
  result: ResultEmitter;
}

interface Issue extends TextDocumentOffset {
  text: string;
  suggestions?: Suggestion[];
  issueType: IssueType;
}

interface RunResult {
  files: number;
  filesWithIssues: Set<string>;
  issues: number;
  errors: number;
}

Reporter System

Text Parser System

Text parsing interfaces for extracting and processing content from different file types with support for nested parsing and scope tracking.

interface Parser {
  readonly name: ParserName;
  parse(content: string, filename: string): ParseResult;
}

interface ParseResult {
  readonly content: string;
  readonly filename: string;
  readonly parsedTexts: Iterable<ParsedText>;
}

interface ParsedText {
  readonly text: string;
  readonly range: Range;
  readonly scope?: Scope;
}

Text Parser System

Types

Core Type Aliases

type Version = VersionLatest | VersionLegacy;
type VersionLatest = "0.2";
type VersionLegacy = "0.1";

type LanguageId = LanguageIdSingle | LanguageIdMultiple;
type LocaleId = string;

type DictionaryReference = DictionaryRef | DictionaryNegRef;
type DictionaryRef = DictionaryId;
type DictionaryNegRef = `!${DictionaryId}`;

type Glob = SimpleGlob | GlobDef;
type SimpleGlob = string;

interface GlobDef {
  glob: string;
  root?: string;
}