-
-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
Taking this file as an example:
import { O } from "ts-toolbelt"
import { FromSchema } from "json-schema-to-ts"
export const leafTypeSchema = {
type: "string",
enum: ["string", "number", "boolean"],
} as const
export type LeafType = FromSchema<typeof leafTypeSchema>
export const objTypeSchema = {
type: "string",
const: "object",
} as const
export type ObjType = FromSchema<typeof objTypeSchema>
export const leafSchema = {
type: "object",
additionalProperties: false,
properties: {
id: { type: "string", format: "uuid" },
key: { type: "string" },
type: leafTypeSchema,
name: { type: "string" },
},
required: ["id", "key", "type", "name"],
} as const
export type Leaf = FromSchema<typeof leafSchema>
export const objSchema = {
$id: "objSchema",
type: "object",
additionalProperties: false,
properties: {
id: { type: "string", format: "uuid" },
key: { type: "string" },
type: objTypeSchema,
name: { type: "string" },
fields: { type: "array", items: { anyOf: [{ $ref: "#" }, leafSchema] } },
},
required: ["id", "key", "type", "name", "fields"],
} as const
export type ObjRaw = FromSchema<typeof objSchema>
export const fieldTypeSchema = {
anyOf: [leafTypeSchema, objTypeSchema],
} as const
export type FieldType = FromSchema<typeof fieldTypeSchema>
export const fieldSchema = {
anyOf: [objSchema, leafSchema],
} as const
export type Field = Obj | Leaf
export type Obj = O.Update<ObjRaw, "fields", Array<Field>>I'm seeing this:
Type of property 'fields' circularly references itself in mapped type '{ id: { type: "primitive"; value: string; isSerialized: false; deserialized: never; }; key: { type: "primitive"; value: string; isSerialized: false; deserialized: never; }; type: { type: "const"; value: "object"; isSerialized: false; deserialized: never; }; name: { ...; }; fields: _$Array<...>; }'. (tsserver 2615)
This was working prior to an update from 1.6 to latest (2.5.5). Recommendation on how to resolve?
tobb-it and barryam3
Metadata
Metadata
Assignees
Labels
No labels