TypeScript errors upgrading CASL Prisma from 1.0.1 to 1.0.2
See original GitHub issueDescribe the bug We’re having troubling upgrading CASL Prisma from 1.0.1 to 1.0.2. Our approach follows the example in the documentation here:
https://www.npmjs.com/package/@casl/prisma
So I’m not sure what we are doing wrong or if this is a bug.
To Reproduce
Prisma file.
model DbMessage {
tenantQid String @map(name: "tenant_qid")
qid String @id
topic String
authorQid String @map(name: "author_qid")
@@map(name: "message")
}
Ability file:
type AppAbility = PrismaAbility<
[
string,
Subjects<{
Message: DbMessage;
}>,
]
>;
const AppAbility = PrismaAbility as AbilityClass<AppAbility>;
const { can, cannot, build } = new AbilityBuilder(AppAbility);
can('read', 'Message', { tenantQid: 'example-qid' });
TypeScript error:
TS2769: No overload matches this call. Overload 1 of 2, '(action: string | string[], subject: "Message" | "Message"[], conditions?: undefined): RuleBuilder<AppAbility>', gave the following error. Argument of type '{ tenantQid: string; }' is not assignable to parameter of type 'undefined'. Overload 2 of 2, '(action: string | string[], subject: "Message" | "Message"[], fields?: string | string[] | undefined, conditions?: undefined): RuleBuilder<AppAbility>', gave the following error. Argument of type '{ tenantQid: string; }' is not assignable to parameter of type 'string | string[] | undefined'. Object literal may only specify known properties, and 'tenantQid' does not exist in type 'string[]'.
Expected behavior Expected no TypeScript error.
Versions
@casl/ability
- 5.4.4
@casl/prisma
- 1.0.2
typescript
- 4.6.4
Environment: Node, TypeScript
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
@casl/prisma - npm
This package allows to define CASL permissions on Prisma models using Prisma WhereInput . And that brings a lot of power in terms...
Read more >How to resolve compile errors during upgrade of Angular ...
So I tried upgrading Typescript to 3.2 and then running “ng serve”, but it gives me this error: ERROR in The Angular Compiler...
Read more >casl - Bountysource
CASL is an isomorphic authorization JavaScript library which restricts what resources a ... Here's a repro of type errors with Prisma 3.14 (same...
Read more >Prisma generate (typescript error) - Questions
My prisma.yml endpoint: http://localhost:4466 datamodel: datamodel.prisma hooks: post-deploy: - prisma generate generate: generator: ...
Read more >CASL is an isomorphic authorization JavaScript library which ...
stalniy/casl, CASL (pronounced /ˈkæsəl/, like castle) is an ... as I want to compile my typescript project using tsc, it just errors out....
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
Not related. You cannot name your models differently, it should be this:
So, the name MUST be
DbMessage
and cannot beMessage
because then CASL cant find related types inside Prisma typesThank you for the report. I’ll take a look at it today