Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large declaration files for flattened zod schema #3472

Open
EllAchE opened this issue May 7, 2024 · 1 comment
Open

Large declaration files for flattened zod schema #3472

EllAchE opened this issue May 7, 2024 · 1 comment

Comments

@EllAchE
Copy link

EllAchE commented May 7, 2024

luluNextData.txt

When emitting declaration files for a complex nested json the resulting declaration file can end up being quite large. I've shared a schema above generated from a large json (next data from a lululemon page) using https://transform.tools/typescript-to-zod. This results in a 17mb declaration file (.d.ts).

A quick look at the .d.ts file shows very large const declaraions of the the zod objects. Anything I can do to reduce this file size? If naively doing this as a human I could just modify the zod schema into an interface/type and avoid declaring the large consts, as the declaration files for inferred types don't need the zod context.

This is in a typescript project with the following tsconfig settings

{
  "compileOnSave": true,
  "compilerOptions": {
    "declaration": true,
    "declarationMap": true,
    "composite": true,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "incremental": true,
    "lib": ["esnext"],
    "module": "commonjs",
    "moduleResolution": "node",
    "noErrorTruncation": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "esnext"
  }
}
@colinhacks
Copy link
Owner

Thanks for this! I've replicated and work on this for Zod 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants