It has different type definitions for some methods used in express and
TypeScript build fails because of it.
The solution is to use @types/express-serve-static-core instead.
The old code was returning a fn because TypeScript could not figure out
generic type parameters when params was an object like:
interface Params<State> {
a: Reducer<State>
b: Partial<State>
}
function test<State>(params: Params<State>) {
// ...
}
The pending action will be modified and a newly created promise handler
will be returned.
This has (suddenly?) caused errors in tests because the catch() handlers defined in tests would be called before the one defined in PromiseMiddleware:
const p = new Promise(...)
const {payload} = store.dispatch({
payload: new Promise(...),
type: '...',
})
try {
await payload
} catch (err) {
// this handler would be invoked before the catch handler in
// PromiseMiddleware
}
since the PromiseMiddleware adds a then-callback, followed by a
catch-callback.
This is to help guard against types that can be undefined since the
recommended eslint rules recommend against using `!` operator on values
like:
const obj: Obj | undefined = ...
obj!.value
Now we can use:
const obj: Obj | undefined = ...
const obj2: Obj = guard(isDefined, obj)
obj.value
The guard function will throw an error if obj parameter is undefined.