TypeScript type definition for promise.reject
问题 The following code is correct in terms of the type that is returned, because then always return the promise array. Promise.resolve(['one', 'two']) .then( arr => { if( arr.indexOf('three') === -1 ) return Promise.reject( new Error('Where is three?') ); return Promise.resolve(arr); }) .catch( err => { console.log(err); // Error: where is three? }) TypeScript throw error: The type argument for type parameter 'TResult' cannot be inferred from the usage. Consider specifying the type arguments