Skip to content

[Feature]: Support for custom casting #94

@Catlike14

Description

@Catlike14

What happened?

I’m using spatie/laravel-model-states, but the cast for the state field is not handled properly. Every time I regenerate my types, I have to manually re-add the type string for every field that it is a state. It would be helpful to support this library, ideally by defining a type with all possible state values instead of a generic string. Alternatively, having a way to implement custom type definitions would solve the issue.

Another improvement could be to set undeterminable types as any, logging a warning in the console. This would help prevent syntax errors that currently require manual fixes (e.g., for git hooks).

How to reproduce the bug

After running php artisan typescriptable the field is empty, causing a syntax error:

export interface MyModel {
    id: number
    state:
    created_at?: string
    updated_at?: string
}

Package Version

3.1

PHP Version

8.4

Which operating systems does with happen with?

No response

Notes

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions