Skip to content

Commit

Permalink
fix(vue): fix setup props type error
Browse files Browse the repository at this point in the history
  • Loading branch information
jrson83 committed May 7, 2024
1 parent 660bdc8 commit 3fb081a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions packages/vue/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ import remember from './remember'
import type { InertiaComponentType } from './types'
import useForm from './useForm'

export interface InertiaAppProps {
initialPage: Page
initialComponent?: object
resolveComponent: PageResolver<InertiaComponentType>
titleCallback?: HeadManagerTitleCallback
onHeadUpdate?: HeadManagerOnUpdate | null
}

const page = ref({}) as Ref<Page>
const layout = shallowRef(null)

Expand All @@ -58,7 +50,10 @@ const App = defineComponent({
default: ((title) => title) as HeadManagerTitleCallback,
},
onHeadUpdate: {
type: Function as PropType<HeadManagerOnUpdate> | null,
type: [
Function,
null,
] as unknown as Object as PropType<HeadManagerOnUpdate | null>,
required: false,
default: () => {},
},
Expand All @@ -75,7 +70,11 @@ const App = defineComponent({
const key = ref<number | string | undefined>(undefined)

const isServer = typeof window === 'undefined'
headManager = createHeadManager(isServer, titleCallback, onHeadUpdate)
headManager = createHeadManager(
isServer,
titleCallback,
onHeadUpdate ? onHeadUpdate : () => {}
)

if (!isServer) {
router.init({
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/src/createInertiaApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
ProgressCallback,
} from '@inertiajs-revamped/core'
import { type Plugin, type App as VueApp, createSSRApp, h } from 'vue'
import App, { type InertiaAppProps, plugin } from './app'
import App, { plugin } from './app'
import type { InertiaComponentType } from './types'

export interface CreateInertiaAppProps {
Expand All @@ -14,7 +14,7 @@ export interface CreateInertiaAppProps {
setup: (props: {
el: HTMLElement | null
App: typeof App
props: InertiaAppProps
props: InstanceType<typeof App>['$props']
plugin: Plugin
}) => void | VueApp
title?: HeadManagerTitleCallback
Expand Down

0 comments on commit 3fb081a

Please sign in to comment.