-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Usage in JavaScript #168
Comments
The strictNullChecks is required for proper static typing, so you're correct that it doesn't affect the runtime execution. There are many closed issues on this repo that will shed some light on the sort of type inference issues you'll experience without strictNullChecks. The biggest issue is that all object properties will be inferred as optional by the type checker. You can use this in a hybrid/JavaScript project just fine. I'll add this to the readme to avoid more confusion down the road 👍 |
Were you able to get this working in a JavaScript project? I'm not accustom to packages being distributed as typescript and it errors my project when trying to use it in a JavaScript project:
If I understand correctly, I'd have to add typescript processing to my app's build pipeline in order to use this, no? Would be great if JS version were distributed too please. |
@websocket98765 what version of Zod do you have installed? |
3.0.0-alpha.24 zod's package.json: "name": "zod",
"version": "3.0.0-alpha.24",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"main": "./lib/cjs/index.js",
"types": "./lib/cjs/index.d.ts",
"module": "./lib/esm/index.js",
"exports": {
"require": "./lib/cjs/index.js",
"import": "./lib/esm/index.js"
}, I imported it via Zod's package.json's "main" is a JavaScript file, so maybe this isn't an issue with zod. It could be something in my build system going wonky--using vite ^2.1.0 via SvelteKit (beta). It's weird that the error makes it appear like it's trying to bring in a ts file. I might mention this to the Vite team. |
Ah yeah I've been hearing about Vite more and more. Seems really interesting. Though I agree this is probably a bug on their end. I have no idea why it would be trying to import |
Hi,
Can this library be used with pure JavaScript (no TypeScript)?
I read the documentation and despite the strictNullChecks requirement and types, it doesn't says can't be used with JavaScript.
I made a test here in a mixed JavaScript/TypeScript project without strictNullChecks and it worked.
I was thinking about using the library in a pure JavaScript project, so I would like to see your opinion and recommendations on the matter, possibly mentioning in the docs.
Thanks.
The text was updated successfully, but these errors were encountered: