Open ciaranmcnulty opened 1 year ago
There doesn't seem to be a good syntax for this - the prior knowledge about the type is lost:
https://psalm.dev/r/1bd9096017
Ideally Psalm would be able to know that the baz key is retained
baz
Maybe something like intersections for arrays would work in future?
/** * @template T of array * @param-out T&array{foo:string,...} $a */
Although on Slack @orklah said if T already contained the foo offset with another type, then the intersection will give you never
if T already contained the foo offset with another type, then the intersection will give you never
I found these snippets:
There doesn't seem to be a good syntax for this - the prior knowledge about the type is lost:
https://psalm.dev/r/1bd9096017
Ideally Psalm would be able to know that the
baz
key is retainedMaybe something like intersections for arrays would work in future?
Although on Slack @orklah said
if T already contained the foo offset with another type, then the intersection will give you never