Skip to content

Figure out ergonomic and scalable way to ensure Zod schemas and types are portable way #896

@jacobsimionato

Description

@jacobsimionato

We have had many issues with Zod schemas. Ideally, we would use schemas in the simplest possible way.

We should investigate:

  • Do we need to document best practices around how to declare types, or can we enforce them programmatically?
  • Can we avoid workarounds in open source code to suit Google's monorepo? Can we just change the compiler settings in Google's mono repo instead?

Google monorepo issue

When imported into google's mono repo, the compiler there erases the types in some circumstances, breaking stuff at runtime

See #872 which addresses this, but adds extra boilerplate.

Lit type inference issue

@ditman has hit issues getting type inference to work properly for Lit. This may affect React too.

He recommends

export const ButtonApi = {
  name: "Button",
  schema: z.object({
    ...
  }).strict(),
} satisfies ComponentApi;

Instead of:

export const ButtonApi: ComponentApi = {
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2sprint readyThis issue should be included in sprint planning views

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions