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

SharedProps returning error when used in usePage hook #46

Open
josevelaz opened this issue Nov 19, 2024 · 3 comments
Open

SharedProps returning error when used in usePage hook #46

josevelaz opened this issue Nov 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@josevelaz
Copy link

josevelaz commented Nov 19, 2024

Package version

1.2.2

Describe the bug

When augmenting the SharedProps interface like shown in the documentation, an error is raised by the usePage<SharedProps>() hook.

 tsserver: Type 'SharedProps' does not satisfy the constraint 'PageProps'.
   Index signature for type 'string' is missing in type 'SharedProps'. [2344]

Passing any value into the module augmentation causes it to break

declare module '@adonisjs/inertia/types' {
  export interface SharedProps extends InferSharedProps<typeof inertiaConfig> {
    props2: string
  }
}

If prop2: string is removed then the error above goes away

image

CleanShot 2024-11-19 at 10 52 14@2x

Reproduction repo

No response

@josevelaz
Copy link
Author

@Julien-R44 reaching out making sure you were able to replicate it?
I was able to replicate it off a new adonisjs project so it seems like its some broken functionality. Happening on v2 aswell, although im aware not much changed from v1 -> v2

@Julien-R44
Copy link
Member

Yup, can confirm this is a bug. I haven't had time to look into it yet. Happy to accept a PR

@Julien-R44 Julien-R44 added the bug Something isn't working label Dec 17, 2024
@Barabasbalazs
Copy link

Barabasbalazs commented Dec 20, 2024

I think that by rewriting the template like this in the config/inerta.ts file,

declare module '@adonisjs/inertia/types' {
  export type SharedProps = InferSharedProps<typeof inertiaConfig> & {
    prop2: string
  }
}

and also removing this interface declaration from the types file can solve this issue:

export interface SharedProps {}

See:

inertia_shared_prop_types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants