Property 'catch' does not exist on type 'ZodNumber'.
See original GitHub issueSorry for bothering you guys. I ran an example from the README.md
and it’s not compiling. Am I doing something wrong?
Code:
import { z } from "zod";
const numberWithCatch = z.number().catch(42);
numberWithCatch.parse(5); // => 5
numberWithCatch.parse("tuna"); // => 42
Error:
/home/<user>/.nvm/versions/node/v16.16.0/lib/node_modules/ts-node/src/index.ts:859
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
trash/zod.ts:3:36 - error TS2339: Property 'catch' does not exist on type 'ZodNumber'.
3 const numberWithCatch = z.number().catch(42);
~~~~~
at createTSError (/home/<user>/.nvm/versions/node/v16.16.0/lib/node_modules/ts-node/src/in
dex.ts:859:12)
at reportTSError (/home/<user>/.nvm/versions/node/v16.16.0/lib/node_modules/ts-node/src/in
dex.ts:863:19)
at getOutput (/home/<user>/.nvm/versions/node/v16.16.0/lib/node_modules/ts-node/src/index.
ts:1077:36)
at Object.compile (/home/<user>/.nvm/versions/node/v16.16.0/lib/node_modules/ts-node/src/i
ndex.ts:1433:41)
at Module.m._compile (/home/<user>/.nvm/versions/node/v16.16.0/lib/node_modules/ts-node/sr
c/index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .ts] (/home/<user>/.nvm/versions/node/v16.16.0
/lib/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
diagnosticCodes: [ 2339 ]
}
Issue Analytics
- State:
- Created 10 months ago
- Reactions:10
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Property 'catch' does not exist on type 'Observable<any>'
I'm assuming the properties Observable are imported as well ( .map works). Looked at the changelog for rxjs.beta-6 and nothing is mentioned ...
Read more >Issues · colinhacks/zod - GitHub
TypeScript-first schema validation with static type inference - Issues ... Zod is really really slow once he detect an error during validation, why...
Read more >[Solved]-Property catch does not exist on type Observable-rx.js
Coding example for the question Property catch does not exist on type ... In newer rxjs versions you have to use the pipe...
Read more >Property 'catch' does not exist on type 'Observable<Response>'
Referência. “Property 'catch' does not exist on type 'Observable '” is published by Leandro Macedo Cotrim.
Read more >Property 'catch' does not exist on type 'Observable<any>'
The Best Answer is Yes, you need to import the operator: import 'rxjs/add/operator/catch'; Or import Observable this way: import {Observable} from 'rxjs/Rx';
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Zod 3.20 just landed, sorry for the confusion!
npm install zod@latest
Is there an estimated date for the next release?