spatie/typescript-transformer

ArrayShapes

Opened this issue · 2 comments

phpdocs with arrayshapes fails.

for exemple: /** @var array{a: int[], b: string[], c: float} $config **/

first it fails at the regexp:

return '/@var ((?:\s?[\\w?|\\\\<>,-]+(?:\[])?)+)/';

then it fails at transpiling (phpDocumentor\Reflection\PseudoTypes\ArrayShape)

default => throw new Exception("Could not transform type: {$type}")

it's partly solved with:

$type instanceof PseudoType => $this->execute($type->underlyingType()),

Senario 1

Input: /** @var array<string, array{a: int[], b: string[], c: float}> $config **/

Expected: {[key: string]: {a: number[], b: string[], c: number}}

Current: RuntimeException Unexpected token "", expected '>' at offset 19 on line 1,
due to the regexp only catching @var array<string, array

Yeah, this is something we're going to handle in v3 which is next big thing I'm working on, it is scomplete rewrite of TS transformer using PHPStan for those things instead of phpDocumentor.

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.