type-inference
This skill teaches you how to work with Biome's type inference engine and module graph architecture for building type-aware lint rules. It covers the three-phase type resolution process—local inference, module-level resolution, and cross-module full inference—plus the TypeReference pattern that prevents stale data in an IDE environment. Use it when implementing new type-aware rules, understanding type resolution, or working on type inference features.
type-inference helps you implement type-aware lint rules by guiding you through Biome's module graph and type resolution architecture.
AI-generated summary based on this skill's SKILL.md
Install
biomejs/biome/type-inference · repository language: Rust
git clone https://github.com/biomejs/biome
cp -r biome/.claude/skills/type-inference ~/.claude/skills/type-inferencenpx skillfed install biomejs/biome/type-inferenceFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I implement type-aware lint rules using Biome's type inference?
Biome's type-inference skill teaches you to build lint rules that leverage the type inference engine. Start by understanding the three-phase resolution process: local inference (within a file), module-level resolution (across a module), and cross-module full inference. Use TypeResolver to access resolved types, and apply the TypeReference pattern to avoid stale data in IDE environments. This approach lets you write rules that understand type relationships and catch type-related issues.
What is the biome module graph architecture and its constraints?
Biome's module graph architecture organizes type information across files without cloning data. The key constraint is that the module graph prevents unnecessary data duplication, which keeps the IDE responsive. The architecture uses TypeData enum variants to represent different type states and ResolvedTypeId structures to track resolved types. Understanding these constraints helps you work within the system's design when implementing cross-file lint rules or resolving types across module boundaries.
How do I resolve types across module boundaries with TypeResolver?
The type-inference skill covers TypeResolver as the core trait for resolving types across modules. TypeResolver handles the three resolution phases and returns ResolvedTypeId structures that point to resolved types. When working with TypeResolver, you access types without cloning them, respecting the module graph's no-cloning constraint. This is essential for implementing lint rules that need to understand types defined in other files or modules.
What does type-inference cover for CSS and HTML class tracking?
Type-inference includes guidance on working with CSS and HTML class tracking within the module graph. This feature allows lint rules to understand class relationships across files, enabling cross-file analysis. The module graph's architecture supports tracking class references and their type information, which is useful for rules that validate styling consistency or detect unused classes.
How do I debug type inference and flattening for new Biome features?
Type-inference provides techniques for debugging the type flattening process and inference engine when building new features. Understanding how TypeData enum variants flow through the three resolution phases helps you trace where inference might fail. The skill covers how Biome's Salsa-based caching system supports type inference, allowing you to identify performance bottlenecks and correctness issues in your type-aware implementations.
What is the TypeReference pattern and why does it matter in Biome?
The TypeReference pattern is central to type-inference and prevents stale type data in IDE environments. Instead of storing direct type references that can become outdated, TypeReference uses indirection to always point to current type information. This design keeps the IDE responsive and accurate, especially when files change. Understanding this pattern is crucial for implementing reliable type-aware lint rules that work correctly across IDE sessions.
SKILL.md
rendered from the published skill — quoted content, verbatim
Purpose
Use this skill when working with Biome's type inference system and module graph. Covers type references, resolution phases, and the architecture designed for IDE performance.
Prerequisites
- Read
crates/biome_js_type_info/CONTRIBUTING.mdfor architecture details - Understand Biome's focus on IDE support and instant updates
- Familiarity with TypeScript type system concepts
Key Concepts
Module Graph Constraint
Critical rule: No module may copy or clone data from another module, not even behind Arc.
Why: Any module can be updated at any time (IDE file changes). Copying data would create stale references that are hard to invalidate.
Solution: Use TypeReference instead of direct type references.
Type Data Structure
Types are stored in TypeData enum
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.claude/skills/type-inference/SKILL.md