Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Not compatible with Eloquence\Behaviours\HasCamelCasing #91

Open
PerryRylance opened this issue Jan 7, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@PerryRylance
Copy link

What happened?

When I install and use kirkbushell/eloquence's HasCamelCasing, this library still generates snake case TypeScript interfaces.

Because the models are serialized with camel case attributes, my interfaces don't reflect how the model actually looks and I either end up with failing type checks or runtime errors due to wrong field names.

I appreciate if first party support for integration isn't desirable - Would you be open to adding a setting for typescriptable.eloquent.printer_class then changing EloquentType.php:38 from

$type->typescript = PrinterEloquentTypescript::make($type->app()->models());

to

$type->typescript = ($type->config()->printerClass)::make($type->app()->models());

This will allow me to subclass \Kiwilan\Typescriptable\Typed\Eloquent\Printer\PrinterEloquentTypescript and hook in with my own printer where I can transform attribute names to camel case :) (Tested locally and working)

I'm unable to open a pull request, happy to fork, I'd prefer to contribute rather than fork if possible.

How to reproduce the bug

  • Install this package
  • Install kirbushell/eloquence
  • Make a model with some snake case fields in the DB
  • Use the HasCamelCasing trait on one of your models
  • Run artisan typescriptable
  • Observe that the generated interfaces have the snake case names

Package Version

3.1.05

PHP Version

8.4

Which operating systems does with happen with?

Linux

Notes

No response

@PerryRylance PerryRylance added the bug Something isn't working label Jan 7, 2025
@ewilan-riviere ewilan-riviere self-assigned this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants