🔎 Search Terms
TS5088, cyclic structure, trivially serialized, declaration emit, elided any, TS 7
🕗 Version & Regression Information
Errors on 7.1.0-dev.20261006.1. 6.0.3 emits /*elided*/ any at the cycle instead. (7.0.2 also emitted /*elided*/ any for both repros below when I tried it, in case that helps narrow anything down.)
⏯ Playground Link
No response
💻 Code
// tsc --declaration --emitDeclarationOnly --strict repro.ts
type show<t> = { [k in keyof t]: t[k] } & unknown
type resolve<$, k extends keyof $> = show<{
[p in keyof $[k]]: $[k][p] extends "ref" ? resolve<$, k> : $[k][p]
}>
declare const mod: <$>() => { [k in keyof $]: resolve<$, k> }
export const n = mod<{ Node: { value: number; next: "ref" } }>()
🙁 Actual behavior
error TS5088: The inferred type of 'n' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary.
🙂 Expected behavior
Same as 6.0.3, which emits:
export declare const n: {
Node: {
value: number;
next: /*elided*/ any;
};
};
Not sure whether the error is intended though! I can see the argument that an error is more honest than quietly writing any into a .d.ts, so if this is intentional, totally fair, but it might be worth calling out as a breaking change.
Additional information about the issue
Ran into this while moving ArkType's repo to TS 7. Here's what it looks like for an ArkType user exporting a scope with a recursive type:
import { scope } from "arktype"
const $ = scope({
Node: { value: "number", "next?": "Node" },
List: { head: "Node" }
})
// 6.0.3: emits, with `next?: /*elided*/ any` at the cycle
// 7.1.0-dev.20261006.1: error TS5088
export const types = $.export()
There's no reasonable annotation for users to write here, since the whole point is that the type is inferred from the definitions, so in practice this is a breaking change for anyone shipping declarations from code like this.
Thanks!
🔎 Search Terms
TS5088, cyclic structure, trivially serialized, declaration emit, elided any, TS 7
🕗 Version & Regression Information
Errors on
7.1.0-dev.20261006.1. 6.0.3 emits/*elided*/ anyat the cycle instead. (7.0.2 also emitted/*elided*/ anyfor both repros below when I tried it, in case that helps narrow anything down.)⏯ Playground Link
No response
💻 Code
🙁 Actual behavior
🙂 Expected behavior
Same as 6.0.3, which emits:
Not sure whether the error is intended though! I can see the argument that an error is more honest than quietly writing
anyinto a .d.ts, so if this is intentional, totally fair, but it might be worth calling out as a breaking change.Additional information about the issue
Ran into this while moving ArkType's repo to TS 7. Here's what it looks like for an ArkType user exporting a scope with a recursive type:
There's no reasonable annotation for users to write here, since the whole point is that the type is inferred from the definitions, so in practice this is a breaking change for anyone shipping declarations from code like this.
Thanks!