Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fully typing for hanko events added via component prop #2

Open
danielroe opened this issue Jun 5, 2023 · 4 comments
Open

fully typing for hanko events added via component prop #2

danielroe opened this issue Jun 5, 2023 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@danielroe
Copy link
Collaborator

No description provided.

@danielroe danielroe added the enhancement New feature or request label Jun 5, 2023
@danielroe danielroe changed the title fully typing for hanko events fully typing for hanko events added via component prop Jun 5, 2023
@danielroe danielroe added help wanted Extra attention is needed good first issue Good for newcomers labels Jun 6, 2023
felix-dolderer pushed a commit to felix-dolderer/nuxt-hanko that referenced this issue Jun 25, 2024
felix-dolderer pushed a commit to felix-dolderer/nuxt-hanko that referenced this issue Jun 25, 2024
@felix-dolderer
Copy link
Contributor

@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?

@danielroe
Copy link
Collaborator Author

danielroe commented Jun 26, 2024

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?

@felix-dolderer
Copy link
Contributor

@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

@danielroe
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants