How to type polymorphic / dynamic attributes? #365
-
I've got a class Stage data where $type is a model from a polymorphic relationship.
I'm stuck trying to type this in the proper way. I've managed to implement it like below, but because of the missing type hint in the constructor, I get
Is it possible to get the typescript type while keeping the dynamic property? |
Beta Was this translation helpful? Give feedback.
Answered by
rubenvanassche
Mar 2, 2023
Replies: 1 comment 1 reply
-
Take a look at this: https://spatie.be/docs/typescript-transformer/v2/usage/annotations#content-using-php-types-to-write-typescript |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
P-James
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Take a look at this: https://spatie.be/docs/typescript-transformer/v2/usage/annotations#content-using-php-types-to-write-typescript