Closed ngekoding closed 8 months ago
Strange bug, I will try to reproduce it, thanks 👍
@ngekoding I try to reproduce your problem, but I can't, can you provide a repository like this one?
https://github.com/ewilan-riviere/laravel-typescriptable-test
Of course, here is the repository: https://github.com/ngekoding/laravel-typescriptable-test
Well, I found the issue when using DB_PREFIX, when trying to remove it, the generated types looks good:
declare namespace App.Models {
export interface User {
id?: number
name: string
email: string
role: string
email_verified_at?: Date
created_at?: Date
updated_at?: Date
password?: any
}
}
So, maybe it is the problem with the prev issue: https://github.com/kiwilan/typescriptable-laravel/issues/44
Thanks, I will fix this soon!
Can you try latest release: 1.11.35?
It seems to have worked now.
Sorry maybe it is a different thing, but as for now I just thinking about the Date
type like for created_at
, how can we cast it to JavaScript Date
as we get string
from the server and passed directly as component props?
Like we have this page component:
// Pages/User/UserList.vue
<script setup lang="ts">
defineProps<{
users: App.Models.User[]
}>
</script>
<template>
<ul>
<li v-for="user in users">The user <b>{{ user.name }}</b> was created on {{ user.created_at }}.</li>
</ul>
</template>
And in the server we have:
$users = User::all();
return Inertia::render('User/UserList', [
'users' => $users
]);
Thanks, I will fix this soon!
Can you try with latest release?
Sorry, will try it as soon as possible.
Solved!
What happened?
The generated types only include some table columns.
Let's say we have this users table columns:
User's model:
And it is what we get:
How to reproduce the bug
Package Version
^1.11.33
PHP Version
8.2.10
Which operating systems does with happen with?
macOS
Notes
No response