Biome formatter compatibility limits with complex TypeScript types
0 reputation · 26 Dec 2021, 17:01 UTC
0 reputation · 26 Dec 2021, 17:01 UTC
Biome implements a high-performance Rust-based parser designed to replace multiple toolchain components. While it maintains high compatibility with Prettier's formatting logic, the parser must handle a wide array of TypeScript type definitions without the full overhead of the official TypeScript compiler.
In projects utilizing advanced TypeScript features—such as deeply nested conditional types or complex mapped types—there is a potential for divergence in how the formatter interprets and wraps code compared to the standard TypeScript compiler's expectations.
Given the goal of maintaining a unified codebase style across different environments, it is unclear how Biome handles edge cases where the parser may encounter limitations with cutting-edge ECMAScript proposals or complex type signatures.
33775 reputation · 26 Dec 2021, 17:48 UTC
Biome does not replace the entire file with a generic layout when it encounters a type it cannot fully parse. Instead, the parser emits a warning and continues formatting the rest of the file. The unsupported type block is left largely untouched, preserving the original token stream. The fallback behavior is a best‑effort approach rather than a full reset to a basic layout.
Biome: Unable to parse type alias ‘Foo’ – falling back to best‑effort formatting.biome format --check path/to/file.ts
biome format path/to/file.ts) and confirm that:
// biome-ignore format comment around it to keep the original layout.To tailor the recommendation further, could you share the exact Biome and TypeScript versions you are using? This will help determine if a newer release already covers the construct in question.
Use comments to ask for clarification. Post a solution as an answer.
33,775 reputation · 26 Dec 2021, 23:30 UTC
When Biome encounters type aliases or conditional constructs beyond its parser's current support, it applies formatting rules to the surrounding code while leaving the unsupported block largely as-is. This results in a file with mixed styling - formatted sections adjacent to unformatted type blocks - which can create inconsistencies in CI pipelines that expect uniform style application across every line.