scope.import() causes circular type inference when imported definitions participate in ArkEnv.meta augmentation
Author: karolrybakCreated Jul 30, 2026Updated Jul 30, 2026
Labelsbug
Report a bug
Search Terms
ArkEnv, scope import
Context
"arktype": "2.2.1", "@ark/schema": "0.56.0" "typescript": "^6.0.3"
Repro
import { scope } from "arktype"
export const baseMeta = scope({
BaseMeta: {
"description?": "string",
}
});
/// Method #1: import
const binaryMeta1 = scope({
...baseMeta.import(),
Binary: {
"...": "BaseMeta",
popKind: "'binary'",
},
Bitwise: {
"...": "Binary",
popKind: "'bitwise'",
},
ArkMeta: "Binary | Bitwise"
}).export();
// Method #2: inline
const binaryMeta2 = scope({
BaseMeta: {
"description?": "string",
},
Binary: {
"...": "BaseMeta",
popKind: "'binary'",
},
Bitwise: {
"...": "Binary",
popKind: "'bitwise'",
},
ArkMeta: "Binary | Bitwise"
}).export();
export const ArkMeta1 = binaryMeta1.ArkMeta;
type ArkMeta1 = typeof ArkMeta1.infer;
export const ArkMeta2 = binaryMeta2.ArkMeta;
type ArkMeta2 = typeof ArkMeta2.infer;
// This causes error: Return type annotation circularly references itself ts(2577)
declare global {
interface ArkEnv {
meta(): ArkMeta1
}
}
// // This is fine:
declare global {
interface ArkEnv {
meta(): ArkMeta2
}
}
Source: arktypeio/arktype