这是indexloc提供的服务,不要输入任何密码
Skip to content

The recursive reference typescript type problem #5439

@javionlog

Description

@javionlog
import { z } from 'zod';

const rowSpec = z.object({
  name: z.string(),
});

/* this not work */
export const treeSpec = z.object({
  ...rowSpec.shape,
  get children() {
    return z.array(treeSpec);
  },
});

/* this work */
export const treeSpec_2 = z.object({
  name: z.string(),
  get children() {
    return z.array(treeSpec_2);
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions