authzed-node icon indicating copy to clipboard operation
authzed-node copied to clipboard

Type Errors when copying the example

Open marceloptoi opened this issue 3 years ago • 7 comments

I've copied & pasted the example from the example folder but got some type errors from typescript from both the WriteRelationshipsRequest and checkPermissionRequest

However, if I add "as any" to the parameters just to get it to compile, the functions work as expected, so it appears to be just something wrong with the type defs.

marceloptoi avatar Dec 13 '22 21:12 marceloptoi

The CheckPermissionRequest error Captura de Tela 2022-12-13 às 18 21 06

And the WriteRelationshipsRequest Captura de Tela 2022-12-13 às 18 21 58

marceloptoi avatar Dec 13 '22 21:12 marceloptoi

@MarceloPeresToi can you provide the version of typescript you're using? I haven't been able to repro the errors using the latest released version (4.9.4)

samkim avatar Dec 28 '22 20:12 samkim

Of course! My bad! I'm using 4.5.2

marceloptoi avatar Dec 28 '22 20:12 marceloptoi

Thanks! I tested again with 4.5.2 and still can't repro.

What's odd is that the error for the CheckPermissionRequest line in the original report shows Type: '{ oneofKind: undefined; }' is not assignable... but the line itself has oneofKind: 'fullyConsistent',.

To rule out IDE setup, can you try running tsc from the command line and see if you get the same errors?

samkim avatar Dec 28 '22 22:12 samkim

Just checked again and I'm using version 4.5.5. Running tsc got me the same errors. I'm using v0.10.0 of authzed-node

marceloptoi avatar Dec 28 '22 22:12 marceloptoi

It's weird because I'm explicitly passing 'fullyConsistent' as value and for some reason it is treated as undefined...

consistency: v1.Consistency.create({
   requirement: {
     oneofKind: 'fullyConsistent',
     fullyConsistent: true,
   },
}),
Type '{ oneofKind: undefined; }' is not assignable to type '{ oneofKind: "minimizeLatency"; minimizeLatency: boolean; } | { oneofKind: "atLeastAsFresh"; atLeastAsFresh: ZedToken; } | { oneofKind: "atExactSnapshot"; atExactSnapshot: ZedToken; } | { ...; }'.

Property 'fullyConsistent' is missing in type '{ oneofKind: undefined; }' but required in type '{ oneofKind: "fullyConsistent"; fullyConsistent: boolean; }'.```

marceloptoi avatar Dec 28 '22 22:12 marceloptoi

I've tried with typescript 4.5.5 and am also using authzed-node v0.10.0 but still no repro. I'm not seeing anything obvious to try next. Perhaps try deleting your node_modules directory and re-installing?

samkim avatar Dec 29 '22 00:12 samkim