assertType not picking up templates as expected #7371
Replies: 5 comments 12 replies
-
|
The assertType('React\Promise\PromiseInterface<bool>', new FulfilledPromise(true));The following error pops up: |
Beta Was this translation helpful? Give feedback.
-
|
This assertion works fine: assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn));However the moment we put an empty assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then()->then($passThroughBoolFn));The following error pops up: |
Beta Was this translation helpful? Give feedback.
-
|
The fix you PRed yesterday helps @rvanvelzen. But it might also contain a critical flaw in how promises work. If I interpret this conditional return statement correctly it looks at which argument is passed or not, but not at which of those callables is called: /**
* @return PromiseInterface<(
* $onFulfilled is not null
* ? ($onRejected is not null ? TFulfilled|TRejected : TFulfilled)
* : ($onRejected is not null ? TRejected : F)
* )>
*/The way promises work both can be called depending on the outcome. For example during the following assertion assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then(null, $passThroughThrowable)->then($passThroughBoolFn));And yields the following errors: Had a discussion yesterday with @clue and @SimonFrings on this. And we're not sure how return types would look like when a promise can resolve into a |
Beta Was this translation helpful? Give feedback.
-
|
Been trying to wrap my head around the fact that I can't seem to change anything in this error list: It seems I cannot find a way to tell it that the |
Beta Was this translation helpful? Give feedback.
-
|
Sorry, it's been a while. But managed to several things solved. Only have one problem to solve at this point and that is functions like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
While working on reactphp/promise#223 to add templates for type safety to
react/promisenot everything was picked up as expected byassertType. I'm pretty sure fixing a few things will resolve most if not all errors currently coming up.Will respond to this discussion with each error I'm seeing once by one. The PR I linked is where I'll push the changes made after fixing once as this spawns multiple files.
Beta Was this translation helpful? Give feedback.
All reactions