-
Notifications
You must be signed in to change notification settings - Fork 663
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
Merging object-like arrays on imported type does not work #8984
Comments
I have encountered this as well :( |
Looks like this is the same as #9603 - see (temporary) "as" fix on that issue |
Another very similar example: https://psalm.dev/r/82a8ee14d5 |
I found these snippets: https://psalm.dev/r/82a8ee14d5<?php
namespace A {
/**
* @psalm-type AType = array{test: string}
*/
class AAA {
}
}
namespace B {
/**
* @psalm-import-type AType from \A\AAA
* @psalm-type BType = array{anotherTest: string}
* @psalm-type Compound = AType&BType
*/
class BBB {
/**
* @param Compound $type
*/
public function useCompoundType($type): void
{
/** @psalm-trace $type */
return;
}
}
}
|
Another one, with minimalistic annotation. |
I found these snippets: https://psalm.dev/r/bce2b8edcb<?php
/**
* @psalm-type TBaseConfiguration=array{type?: string, ...<string, mixed>}
* @psalm-type TConfiguration=array{name: string}&TBaseConfiguration
*/
class Working2 {}
/** @psalm-type TBaseConfiguration=array{type?: string, ...<string, mixed>} */
class BaseClass {}
/**
* @psalm-import-type TBaseConfiguration from BaseClass
* @psalm-type TConfiguration=array{name: string}&TBaseConfiguration
*/
class BrokenDueToImportedType1 {}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using intersection types, it is possible to extend array shapes as described here.
This works fine:
However, if I want to do the same when one of the types is imported from another file, I get an error from psalm:
This will produce the following error:
The text was updated successfully, but these errors were encountered: