spatie/typescript-transformer

Pick up the `DataCollectionOf` attribute from spatie/laravel-data

Closed this issue · 1 comments

Currently, when creating typescript definitions of spatie/laravel-data objects, it's required to add an docblock static the arrayable type of the property:

#[TypeScript]
class UserData extends Data {
    public function __construct(
        public string $name,
        /** @var PostData[] $posts */
        #[DataCollectionOf(PostData::class)]
        public DataCollection $posts,
    ) {}
}

It would be great if it was possible to remove the docblock there and infer the type from the DataCollectionOf attribute.

I'm considering making a PR for this, it does not sound THAT hard. I would appreciate a little guidance, though - some of the code can be quite hard to follow.