colinhacks / zod

TypeScript-first schema validation with static type inference
https://zod.dev
MIT License
33.09k stars 1.15k forks source link

zod import triggers an error in typescript #3737

Closed uriva closed 1 week ago

uriva commented 2 weeks ago

tsx v4.19.0 node v22.7.0 zod version: "^3.23.8"

tsconfig:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "NodeNext",
    "allowImportingTsExtensions": true,
    "moduleResolution": "NodeNext",
    "noEmit": true,
    "esModuleInterop": true,
    "strict": true
  }
}

code:

import { z } from "zod";

yields in vscode

Cannot find module 'zod' or its corresponding type declarations.ts(2307)

but running it works

Char99s commented 1 week ago

Can you try it like this?

{ "compilerOptions": { "target": "ESNext", "module": "ESNext", "allowImportingTsExtensions": true, "moduleResolution": "Bundler", "noEmit": true, "esModuleInterop": true, "strict": true } }

uriva commented 1 week ago

actually now it works. weird.