Package version
4.2.0
Describe the bug
When defining a page props with the generated types from '@generated/data in a Vue page with Data.*, the inferred props type in the ctx.inertia.render function is any.
// inertia/pages/auth/login.vue
import { Data } from '@generated/data'
defineProps<{ foo: Data.User }>()
// app/controllers/session_controllers.ts
import type { HttpContext } from '@adonisjs/core/http'
export default class SessionController {
async create({ inertia }: HttpContext) {
return inertia.render('auth/login', {
foo: 'any', // The inferred type of "foo" is "any"
})
}
}
The issue is visible when defining a Data.* object at the root level (defineProps<{ foo: Data.User }>())
but when defining an array defineProps<{ foo: Data.User[] }>, the inferred type is shown as Data.User[] but Data.User is still any.
// inertia/pages/auth/login.vue
import { Data } from '@generated/data'
defineProps<{ arrayFoo: Data.User[] }>()
// app/controllers/session_controllers.ts
import type { HttpContext } from '@adonisjs/core/http'
export default class SessionController {
async create({ inertia }: HttpContext) {
return inertia.render('auth/login', {
arrayFoo: ['any', 1],
// The inferred type is correct (PagePropsEagerDataTypes<Data.User[]> | MergeableProp<UnPackedPageProps<Data.User[]>>)
// but "Data.User" is still considered as "any" since the function accepts "['any', 1]"
})
}
}
Note: there is not such issue when using Inertia + React
Reproduction repo
https://github.com/flozdra/inertia-render-props-vue
Package version
4.2.0
Describe the bug
When defining a page props with the generated types from
'@generated/datain a Vue page withData.*, the inferred props type in thectx.inertia.renderfunction isany.The issue is visible when defining a
Data.*object at the root level (defineProps<{ foo: Data.User }>())but when defining an array
defineProps<{ foo: Data.User[] }>, the inferred type is shown asData.User[]butData.Useris still any.Note: there is not such issue when using Inertia + React
Reproduction repo
https://github.com/flozdra/inertia-render-props-vue