Type maps are JSON files that describe every declaration in a CLS source file — functions with full parameter signatures, variables with their types, classes with their members, interfaces, structures, modules, and imports. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/elfrask/cls/llms.txt
Use this file to discover all available pages before exploring further.
clx maptype subcommand generates them by lexing and parsing each .clsx or .clsi file and extracting structured metadata into .type.json files that the VS Code extension and LSP server can read without re-parsing source code on every keystroke. They are the bridge between your source and the editor’s autocomplete, hover documentation, and type-aware completion.
Generating Type Maps
clx maptype walks it recursively, skips .-prefixed directories and well-known build output folders (modules/, dist/, libs/, target/), and preserves the relative directory structure inside the output directory. For example, src/utils/math.clsx becomes .cls-types/src/utils/math.type.json.
When the input is a single file, the -o flag can point to either a directory (the .type.json will be placed inside it) or an explicit output path.
Default output directory is ./.cls-types/ when -o / --out is omitted.
Watch Mode
Pass--watch (or -w) to keep clx maptype running. It polls for file modifications every 2 seconds using mtime comparison and regenerates only the files that changed:
What Type Maps Contain
Each.type.json file is a TypeMap object with two top-level keys:
| Key | Type | Description |
|---|---|---|
source | string | Path of the source file that was parsed |
entries | TypeEntry[] | Array of extracted declarations |
TypeEntry carries:
| Field | Description |
|---|---|
name | Declaration name |
kind | "function", "async function", "variable", "constant", "class", "structure", "interface", "module", "namespace", "import" |
line / col / end_line / end_col | Source location (1-indexed) |
doc | Extracted @description text |
version | From @version annotation, if present |
deprecated | From @deprecated annotation, if present |
signature | Full call signature string (e.g. "add(a: int, b: int) -> int") |
params | Array of { name, type_, doc } objects |
return_type | Return type string, or null |
return_doc | From @return annotation |
fields | For structures and classes: array of { name, type_ } |
members | For classes, interfaces, modules, namespaces: member name list |
type_ | For variables and constants: declared type |
value | Reserved, currently null |
Documentation Annotations in .clsx
clx maptype reads # @tag comments written directly above a declaration. All annotation lines must start with # @ (or #@):
| Tag | Appears in | Description |
|---|---|---|
@description | doc field | Summary shown in hover tooltips |
@params <name> <text> | params[i].doc | Per-parameter documentation |
@return <type> <text> | return_doc | Return value documentation |
@version <semver> | version | API version |
@deprecated <reason> | deprecated | Deprecation notice (shown with strikethrough in hover) |
# @title comment is treated as a module-level separator and stops upward annotation scanning, so module headers do not bleed into the first function’s docs.
.clsi Interface Files
.clsi files are pure type declaration files — they contain function signatures, variable declarations, interfaces, classes, and structures with no implementation. The standard library ships its type information as .clsi files in cls-runtime/clsi/:
clx maptype processes .clsi files the same way it processes .clsx files. The LSP server embeds all builtin .clsi definitions directly in the binary via include_str!, so they are always available without any file lookup.
Example: core.type.json
The following is the real generated type map for cls-runtime/clsi/core.clsi, which describes the CLS intrinsic functions:
core.clsi type map also includes toString, int, float, str, bool, type, now, exit, sleep, and throw.
Integration with VS Code
Whencls.options.unnestableFeatures.useMapClsi is true (the default), the VS Code extension reads every .type.json file found under .cls-types/ in the workspace root and adds its entries to the completion list. As you type, the extension queries these maps for:
- Function completions — name, signature, parameter hints
- Variable completions — name and declared type
- Module completions — module name and its member list
- Hover documentation —
doc,params,return_doc,deprecatedfields rendered as Markdown
clx lsp) uses the same type map data loaded via type_defs::load_all_type_definitions, which merges the embedded builtin definitions with any workspace .clsi files found in a clsi/ directory at the project root.