ITADN

Migration from `@sinclair/typebox` to `typebox` triggers TS7056 and can't infer types

#1544Closedrubenferreira97 创建于 2026-03-09
R
rubenferreira97commented
After migrating from `@sinclair/typebox@0.34.48` to `typebox@1.1.6`, I’m seeing two regressions in generic schema helpers: 1. `tsgo --build` now fails with `TS7056` on helpers that previously compiled. `tsc --build` crashes with `FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory`. 2. In one case, the inferred `Static` type is no longer equivalent to the old package behavior. This repro uses: - `@sinclair/typebox`: `0.34.48` - `typebox`: `1.1.6` - `@typescript/native-preview`: `7.0.0-dev.20260308.1` - `typescript`: `5.9.3` ### Reproduction Repo link: https://github.com/rubenferreira97/typebox_migration - `src/literal/old.ts`: ``` type Order = Query["orderField"]; // ✔️ type Order = "age" | "id" | "name" | undefined type Name = Query["name"]; // ✔️ type Name = string | undefined ``` - ❌ `src/literal/new.ts` (The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed. `(ts7056)`): ``` type Order = Query["orderField"]; // ❌ type Order = undefined type Name = Query["name"]; // ✔️ type Name = string | undefined ``` - `src/union/old.ts`: ``` type Order = Query["orderField"]; // ✔️ type Order = "age" | "id" | "name" | undefined type Name = Query["name"]; // ✔️ type Name = string | undefined ``` - ❌ `src/union/new.ts` (The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed. `(ts7056)`): ``` type Order = Query["orderField"]; // ✔️ type Order = "age" | "id" | "name" | undefined type Name = Query["name"]; // ✔️ type Name = string | undefined ``` ### Notes Run `bun/npm run build:tsgo` or `bun/npm run build:tsc` to check for build errors. While I usually prefer to rely on type inference, I am unable to explicitly set return types in the new version: ❌ [literal/new.ts](https://github.com/rubenferreira97/typebox_migration/blob/4ffb23dc7c5378fd5acf386cbc4b3036cf623863/src/literal/new.ts#L11) ✔️ [literal/old.ts](https://github.com/rubenferreira97/typebox_migration/blob/4ffb23dc7c5378fd5acf386cbc4b3036cf623863/src/literal/old.ts#L11) ❌ [union/new.ts](https://github.com/rubenferreira97/typebox_migration/blob/4ffb23dc7c5378fd5acf386cbc4b3036cf623863/src/union/new.ts#L11) ✔️ [union/old.ts](https://github.com/rubenferreira97/typebox_migration/blob/4ffb23dc7c5378fd5acf386cbc4b3036cf623863/src/union/old.ts#L11)
关闭于 2026-03-10 5 条评论