hanko icon indicating copy to clipboard operation
hanko copied to clipboard

fully typing for hanko events added via component prop

Open danielroe opened this issue 2 years ago • 4 comments

danielroe avatar Jun 05 '23 16:06 danielroe

@danielroe It seems like I don't quite understand something regarding the type definitions in the published version of the module.

When I run pnpm dev:prepare from the root of the repository, I get the correct types for event.context.hanko in API-routes in the playground demo. However if I use the module the "normal" way, by running pnpm i and pnpm dev directly in the playground directory, I don't get the type information (then it's typed as any like before).

Do you have any insights into what's happening / how this can be fixed?

felix-dolderer avatar Jun 26 '24 16:06 felix-dolderer

~~Ah, we probably need to add the underlying package providing the types with typescript.hoist.~~

Tested this, seems to be working fine in a fresh project.

CleanShot 2024-07-01 at 12 33 48@2x

Any chance you could provide a reproduction @felix-dolderer?

danielroe avatar Jun 26 '24 17:06 danielroe

@danielroe Sorry, my message was not very specific. Using await verifyHankoEvent(event) works fine, but when accessing the event.context.hanko property directly, it is typed as any.

Screenshot 2024-07-01 at 13 37 44 Screenshot 2024-07-01 at 13 37 50

While writing this I noticed that I probably misunderstood something on my side. Before verifying the event we can't know if the property exists. The only sensible type-information we could provide there would be HankoPayload | undefined

felix-dolderer avatar Jul 01 '24 11:07 felix-dolderer

No, you're right. The issue is that we're augmenting the type in the 'vue' side of the app rather than in the 'nitro' side. We don't currently have a way to do that easily so that's probably a feature we need in Nuxt.

danielroe avatar Jul 02 '24 20:07 danielroe