#Inertia + Vue + TS

1 messages · Page 1 of 1 (latest)

hushed temple
#

Hi im having problems with TS detecting the correct type. This is what i have in a vue template

        <Link v-if="!$page.props.auth.user" :href="route('login')">
        Log In
        </Link>

'__VLS_ctx.$page.props.auth' is of type 'unknown'.ts(18046)

and they are coming from the inertiarequest handler

    /**
     * Define the props that are shared by default.
     *
     * @return array<string, mixed>
     */
    public function share(Request $request): array
    {
        return array_merge(parent::share($request), [
            'auth' => [
                'user' => $request->user(),
                'canLogin' => Route::has('login'),
                'canRegister' => Route::has('register'),
            ],
            'ziggy' => function () use ($request) {
                return array_merge((new Ziggy)->toArray(), [
                    'location' => $request->url(),
                ]);
            },
        ]);
    }

any idea what i need to define?

hushed temple
#

ah well just added it to a types file not sure if thats correct

sturdy token
#

Yeah, you'd have to create those types yourself. Either write them, or generate them using something like spatie/laravel-data