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.

Typescript validation error when using groupBy

See original GitHub issue

Bug description

Using groupBy and not specifying a fixed value for the having attribute results in several typescript validation errors. Errors occur both when assigned as “Prisma.CategoryGroupByArgs” and “any”.

Снимок экрана 2021-04-10 в 12 59 55

Expected behavior

No validation error occurs

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Node.js version: 14.15.4
  • Prisma version: 2.20.1

Error

`src/api/categories/categories.service.ts:53:18 - error TS2615: Type of property ‘AND’ circularly references itself in mapped type ‘{ [K in keyof { AND?: Enumerable<CategoryScalarWhereWithAggregatesInput>; OR?: Enumerable<CategoryScalarWhereWithAggregatesInput>; … 15 more …; parentId?: number | IntNullableWithAggregatesFilter; }]: Or<…> extends 1 ? { …; }[K] extends infer TK ? GetHavingFields<…> : never : {} extends FieldPaths<…> ? n…’.

53 return await this.prisma.category.groupBy(data); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/api/categories/categories.service.ts:53:18 - error TS2615: Type of property ‘NOT’ circularly references itself in mapped type ‘{ [K in keyof { AND?: Enumerable<CategoryScalarWhereWithAggregatesInput>; OR?: Enumerable<CategoryScalarWhereWithAggregatesInput>; … 15 more …; parentId?: number | IntNullableWithAggregatesFilter; }]: Or<…> extends 1 ? { …; }[K] extends infer TK ? GetHavingFields<…> : never : {} extends FieldPaths<…> ? n…’.

53 return await this.prisma.category.groupBy(data); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/api/categories/categories.service.ts:53:18 - error TS2615: Type of property ‘OR’ circularly references itself in mapped type ‘{ [K in keyof { AND?: Enumerable<CategoryScalarWhereWithAggregatesInput>; OR?: Enumerable<CategoryScalarWhereWithAggregatesInput>; … 15 more …; parentId?: number | IntNullableWithAggregatesFilter; }]: Or<…> extends 1 ? { …; }[K] extends infer TK ? GetHavingFields<…> : never : {} extends FieldPaths<…> ? n…’.

53 return await this.prisma.category.groupBy(data); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/api/categories/categories.service.ts:53:47 - error TS2345: Argument of type ‘CategoryGroupByArgs’ is not assignable to parameter of type ‘({ where?: CategoryWhereInput; orderBy?: Enumerable<CategoryOrderByInput>; by: (“id” | “createdAt” | “updatedAt” | “published” | … 10 more … | “parentId”)[]; … 7 more …; max?: CategoryMaxAggregateInputType; } & { …; } & Error: Field "${any}" used in "having" needs to be provided in "by".) | ({ …; } & …’. Type ‘CategoryGroupByArgs’ is not assignable to type ‘{ where?: CategoryWhereInput; orderBy?: Enumerable<CategoryOrderByInput>; by: (“id” | “createdAt” | “updatedAt” | “published” | … 10 more … | “parentId”)[]; … 7 more …; max?: CategoryMaxAggregateInputType; } & { …; } & […]’. Type ‘CategoryGroupByArgs’ is not assignable to type ‘{ orderBy: Enumerable<CategoryOrderByInput>; }’. Property ‘orderBy’ is optional in type ‘CategoryGroupByArgs’ but required in type ‘{ orderBy: Enumerable<CategoryOrderByInput>; }’.

53 return await this.prisma.category.groupBy(data);`

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
rfermanncommented, Apr 21, 2021

Same issue here, with global and local typescript versions both being 4.2.4. Behaviour is the same as for @DennieMello.

Can you please reopen the issue and investigate?

0reactions
matthewmuellercommented, Jun 30, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Get validation error list of form control in angular 6
I'm using angular 6 with reactive forms. I want to show validation messages dynamically. And I wrote some code like below.
Read more >
How TypeScript 4.9 `satisfies` Your Prisma Workflows
Learn how TypeScript 4.9's new `satisfies` operator can help you write type-safe code with Prisma.
Read more >
Data Validation: DevExtreme - JavaScript UI ... - DevExpress
It describes how to validate a single editor or a group of editors, display the validation summary, perform remote validation, use a custom...
Read more >
4 Ideas of how to harness the power of Typescript generic ...
How... Tagged with typescript, javascript, beginners, tutorial. ... Map by key; Group by key; Merge; Sort ... randomKey // error ...
Read more >
Changelog · dataframe-js - Guillaume Mousnier
groupBy is now faster thanks to @rjrivero. DataFrame can now be created from empty Array without throwing an error. DataFrame column inference during ......
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