v2 beta: Type 'Shape' does not satisfy the constraint 'ZodRawShape'
See original GitHub issueWhen compiling with zod@2.0.0-beta.9
on TypeScript 4.0.3
, I get this error:
node_modules/zod/lib/src/helpers/partialUtil.d.ts(11,39): error TS2344: Type 'Shape' does not satisfy the constraint 'ZodRawShape'.
node_modules/zod/lib/src/helpers/partialUtil.d.ts(11,94): error TS2344: Type '{ [k in keyof Shape]: DeepPartial<Shape[k]>; }' does not satisfy the constraint 'ZodRawShape'.
Type 'DeepPartial<Shape[k]>' is not assignable to type 'ZodTypeAny'.
Type '{ object: Shape[k] extends ZodObject<infer Shape, infer Params, ZodTypeAny, { [k in keyof addQuestionMarks<{ [k in keyof infer Shape]: infer Shape[k]["_output"]; }>]: addQuestionMarks<...>[k]; }, { [k in keyof addQuestionMarks<...>]: addQuestionMarks<...>[k]; }> ? ZodOptional<...> : never; rest: ReturnType<...>; }[S...' is not assignable to type 'ZodType<any, any, any>'.
Type '{ object: Shape[k] extends ZodObject<infer Shape, infer Params, ZodTypeAny, { [k in keyof addQuestionMarks<{ [k in keyof infer Shape]: infer Shape[k]["_output"]; }>]: addQuestionMarks<...>[k]; }, { [k in keyof addQuestionMarks<...>]: addQuestionMarks<...>[k]; }> ? ZodOptional<...> : never; rest: ReturnType<...>; }[S...' is not assignable to type 'ZodType<any, any, any>'.
Type '{ object: Shape[k] extends ZodObject<infer Shape, infer Params, ZodTypeAny, { [k in keyof addQuestionMarks<{ [k in keyof infer Shape]: infer Shape[k]["_output"]; }>]: addQuestionMarks<...>[k]; }, { [k in keyof addQuestionMarks<...>]: addQuestionMarks<...>[k]; }> ? ZodOptional<...> : never; rest: ReturnType<...>; }[S...' is not assignable to type 'ZodType<any, any, any>'.
Type '{ object: Shape[k] extends ZodObject<infer Shape, infer Params, ZodTypeAny, { [k in keyof addQuestionMarks<{ [k in keyof infer Shape]: infer Shape[k]["_output"]; }>]: addQuestionMarks<...>[k]; }, { [k in keyof addQuestionMarks<...>]: addQuestionMarks<...>[k]; }> ? ZodOptional<...> : never; rest: ReturnType<...>; }[S...' is not assignable to type 'ZodType<any, any, any>'.
Type '(Shape[k] extends ZodObject<infer Shape, infer Params, ZodTypeAny, { [k in keyof addQuestionMarks<{ [k in keyof infer Shape]: infer Shape[k]["_output"]; }>]: addQuestionMarks<{ [k in keyof infer Shape]: infer Shape[k]["_output"]; }>[k]; }, { [k in keyof addQuestionMarks<...>]: addQuestionMarks<...>[k]; }> ? ZodOptio...' is not assignable to type 'ZodType<any, any, any>'.
Type 'ReturnType<Shape[k]["optional"]>' is not assignable to type 'ZodType<any, any, any>'.
Type 'unknown' is not assignable to type 'ZodType<any, any, any>'.
Type 'ReturnType<Shape[keyof Shape]["optional"]>' is not assignable to type 'ZodType<any, any, any>'.
Type 'unknown' is not assignable to type 'ZodType<any, any, any>'.
Type 'ReturnType<Shape[string | number | symbol]["optional"]>' is not assignable to type 'ZodType<any, any, any>'.
Type 'unknown' is not assignable to type 'ZodType<any, any, any>'.
Type 'ReturnType<Shape[string]["optional"]> | ReturnType<Shape[number]["optional"]> | ReturnType<Shape[symbol]["optional"]>' is not assignable to type 'ZodType<any, any, any>'.
Type 'ReturnType<Shape[string]["optional"]>' is not assignable to type 'ZodType<any, any, any>'.
Type 'unknown' is not assignable to type 'ZodType<any, any, any>'.
node_modules/zod/lib/src/helpers/partialUtil.d.ts(12,45): error TS2344: Type 'Shape[k]' does not satisfy the constraint 'ZodTypeAny'.
Type 'Shape[keyof Shape]' is not assignable to type 'ZodType<any, any, any>'.
Type 'Shape[string] | Shape[number] | Shape[symbol]' is not assignable to type 'ZodType<any, any, any>'.
Type 'Shape[string]' is not assignable to type 'ZodType<any, any, any>'.
zod@1.11.9
compiles fine- When looking at
node_modules/zod/lib/src/helpers/partialUtil.d.ts(11,39)
I see red squiggles in VS Code. I suspect it could be a type error in the library.
My tsconfig.json
:
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2019",
"strict": true,
"outDir": "dist",
"esModuleInterop": true
},
"include": ["src"]
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Type 'Shape' does not satisfy the constraint 'ZodRawShape ...
When compiling with zod@2.0.0-beta.9 on TypeScript 4.0.3, I get this error: node_modules/zod/lib/src/helpers/partialUtil.d.ts(11,39): error ...
Read more >Type 'MyType' does not satisfy the constraint 'ObjectShape ...
Instead of specifying the interface to the object, do it to the shape with a Record - <Record<keyof MyType, yup.AnySchema>> .
Read more >No more need for `extends` in type definitions! : r/typescript
This approach still refines the type T and the compiler throws when it doesn't extend ZodRawShape . As I'm using composing this interface...
Read more >ZodObject not inferred when using ZodSchema #858 - bytemeta
TS2344 : Type 'ActiveService' does not satisfy the constraint 'ZodRawShape'. Index signature for type 'string' is missing in type 'ActiveService'.
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
@pepakriz I’ve created a new issue (#192) and opened a PR (#193) which should fix it.
@MajorBreakfast found that build works with “2.0.0-beta.5”