Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ctrlaltdelme's avatar

Generate Typescript types for Models?

Is there a way to generate Typescript types for Models? I see that when I installed the Inertia + Vue starter kit, User was defined already in an index.d.ts file. Do I just put my types in that same file? Is there a convention for where types get stored or created? Is there a package that helps with this automatically? I've heard of Laravel Data but don't know if it's a good solution for me, or overkill.

0 likes
6 replies
ctrlaltdelme's avatar

So I don't need Laravel Data to do this? I can just use that package and be good to go? Seems Laravel Data has this bundled into it maybe? Or at least, the TS types generation part.

ctrlaltdelme's avatar

Wayfinder seems really useful! Seems like a really nice DX package. Will definitely use this as-is plus the Spatie package. This is awesome! Thanks!

Jeffrey has an awesome video on Wayfinder too!

ctrlaltdelme's avatar

So it looks like Typescript Transformer only transforms Enums and PHP classes and not Models? Is that right? How would I transform my models too?

I think in the Spatie docs, they use a DTO, but I dont understand how to use them

JeffreyWay's avatar

The update to Laravel Wayfinder (first party package) will include support for this.

Automatically generates client-side type definitions and JS for backend route definitions, form requests, Inertia props, enums, and more. That means fewer errors and better alignment between backend and frontend code.

1 like
ctrlaltdelme's avatar

The goat himself responded. So, it definitely will include TS types generation. That is fantastic! Thanks Jeff! Watching your video between afternoon kid shenanigans and it's super informative. Thanks!

1 like

Please or to participate in this conversation.