question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property 'catch' does not exist on type 'ZodNumber'.

See original GitHub issue

Sorry 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:closed
  • Created 10 months ago
  • Reactions:10
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
colinhackscommented, Dec 12, 2022

Zod 3.20 just landed, sorry for the confusion! npm install zod@latest

4reactions
jsouto18commented, Nov 26, 2022

Is there an estimated date for the next release?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found