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

$page type not defined #1382

Closed
nurdism opened this issue Jan 14, 2023 · 6 comments · Fixed by #1393
Closed

$page type not defined #1382

nurdism opened this issue Jan 14, 2023 · 6 comments · Fixed by #1393
Assignees

Comments

@nurdism
Copy link

nurdism commented Jan 14, 2023

Version:

  • @inertiajs/vue3 version: 1.0.0

Describe the problem:

$page type for ComponentCustomProperties is not defined in the typings for @inertiajs/vue3

@martinbean
Copy link

I’m getting the same too with code like this:

<Link
  v-bind:class="{ 'active': $page.component === 'Dashboard' }"
  v-bind:href="dashboardUrl"
>Dashboard</Link>

The error I get in Visual Studio Code is:

Property '$page' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<Readonly<ExtractPropTypes<{}>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => ...'.ts(2339)

@nurdism
Copy link
Author

nurdism commented Jan 14, 2023

I think the issue might be that types.ts never gets exported in index.ts where typescript is trying to pickup its types.

@nurdism
Copy link
Author

nurdism commented Jan 14, 2023

As a temp fix you can declare your own types like this:

import type { Page } from '@inertiajs/core'
declare module '@vue/runtime-core' {
  interface ComponentCustomProperties {
    $page: Page
  }
}

@rev4324
Copy link

rev4324 commented Jan 17, 2023

You can also just import types.ts into your own .d.ts file as another temporary fix:

import Types from "@inertiajs/vue3/types/types"

@iraklisg
Copy link

The last release (1.0.0) does not include that fix. Is it going to be included in a future patch?

@martinbean
Copy link

@reinink Hey, any news on what version this fix will be included in and a ETA on release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants