|
14 | 14 | $passThroughThrowable = static function (Throwable $t): PromiseInterface {
|
15 | 15 | return reject($t);
|
16 | 16 | };
|
| 17 | +$stringOrInt = function (): string|int { |
| 18 | + return time() % 2 ? 'string' : time(); |
| 19 | +}; |
17 | 20 | $tosseable = new Exception('Oops I did it again!');
|
18 | 21 |
|
19 | 22 | assertType('React\Promise\PromiseInterface<bool>', resolve(true));
|
20 |
| -assertType('React\Promise\PromiseInterface<array<bool>>', all([resolve(true), resolve(false)])); |
21 |
| -assertType('React\Promise\PromiseInterface<array<bool>>', all([resolve(true), false])); |
22 |
| -assertType('React\Promise\PromiseInterface<array<bool|int>>', all([resolve(true), resolve(time())])); |
23 |
| -assertType('React\Promise\PromiseInterface<array<bool|int>>', all([resolve(true), time()])); |
24 |
| -assertType('React\Promise\PromiseInterface<array<bool|int>>', all([true, resolve(time())])); |
25 |
| -assertType('React\Promise\PromiseInterface<bool>', race([resolve(true), resolve(true)])); |
26 |
| -assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn)); |
27 |
| -assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then()->then($passThroughBoolFn)); |
28 |
| -assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then(null)->then($passThroughBoolFn)); |
29 |
| -assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn)->then($passThroughBoolFn)); |
30 |
| -assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn, $passThroughThrowable)->then($passThroughBoolFn)); |
| 23 | +//assertType('React\Promise\PromiseInterface<string|int>', resolve($stringOrInt())); |
| 24 | +assertType('React\Promise\PromiseInterface<int|string>', resolve($stringOrInt())); |
| 25 | +assertType('React\Promise\PromiseInterface<bool>', resolve(resolve(true))); |
| 26 | +//assertType('React\Promise\PromiseInterface<array<bool>>', all([resolve(true), resolve(false)])); |
| 27 | +//assertType('React\Promise\PromiseInterface<array<bool>>', all([resolve(true), false])); |
| 28 | +//assertType('React\Promise\PromiseInterface<array<bool|int>>', all([resolve(true), resolve(time())])); |
| 29 | +//assertType('React\Promise\PromiseInterface<array<bool|float>>', all([resolve(true), hrtime()])); |
| 30 | +//assertType('React\Promise\PromiseInterface<array<bool|int>>', all([true, resolve(time())])); |
| 31 | +//assertType('React\Promise\PromiseInterface<bool>', race([resolve(true), resolve(true)])); |
| 32 | +//assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn)); |
| 33 | +//assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then()->then($passThroughBoolFn)); |
| 34 | +//assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then(null)->then($passThroughBoolFn)); |
| 35 | +//assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn)->then($passThroughBoolFn)); |
| 36 | +//assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn, $passThroughThrowable)->then($passThroughBoolFn)); |
31 | 37 | assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then(null, $passThroughThrowable)->then($passThroughBoolFn));
|
32 |
| -assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then()->then(null, $passThroughThrowable)->then($passThroughBoolFn)); |
33 |
| -assertType('React\Promise\FulfilledPromise<bool>', new FulfilledPromise(true)); |
34 |
| -assertType('React\Promise\PromiseInterface<bool>', (new FulfilledPromise(true))->then($passThroughBoolFn)); |
| 38 | +//assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then()->then(null, $passThroughThrowable)->then($passThroughBoolFn)); |
| 39 | +//assertType('React\Promise\FulfilledPromise<bool>', new FulfilledPromise(true)); |
| 40 | +//assertType('React\Promise\PromiseInterface<bool>', (new FulfilledPromise(true))->then($passThroughBoolFn)); |
35 | 41 |
|
36 |
| -//assertType('React\Promise\PromiseInterface<Throwable>', reject($tosseable)); |
37 |
| -//assertType('React\Promise\PromiseInterface<Throwable>', reject($tosseable)->then($passThroughBoolFn, $passThroughThrowable)); |
38 |
| -//assertType('React\Promise\PromiseInterface<Throwable>', reject($tosseable)->then()->then($passThroughBoolFn, $passThroughThrowable)); |
39 |
| -//assertType('React\Promise\PromiseInterface<Throwable>', reject($tosseable)->then(null, $passThroughThrowable)); |
40 |
| -//assertType('React\Promise\PromiseInterface<Throwable>', reject($tosseable)->then()->then(null, $passThroughThrowable)); |
| 42 | +//assertType('React\Promise\PromiseInterface<null, Exception>', reject($tosseable)); |
| 43 | +//assertType('React\Promise\PromiseInterface<null, Throwable>', reject($tosseable)); |
| 44 | +//assertType('React\Promise\PromiseInterface<null, Throwable>', reject($tosseable)->then($passThroughBoolFn, $passThroughThrowable)); |
| 45 | +//assertType('React\Promise\PromiseInterface<null, Throwable>', reject($tosseable)->then()->then($passThroughBoolFn, $passThroughThrowable)); |
| 46 | +//assertType('React\Promise\PromiseInterface<null, Throwable>', reject($tosseable)->then(null, $passThroughThrowable)); |
| 47 | +//assertType('React\Promise\PromiseInterface<null, Throwable>', reject($tosseable)->then()->then(null, $passThroughThrowable)); |
0 commit comments