TypeScript Version: 3.8.3
Search Terms:
Expected behavior:
broken should have the same type as working.
Actual behavior:
broken has an added never[] type.
Related Issues:
Code
const gotoThen = Promise.resolve(123);
const gotoCatch = Promise.reject();
// const working: Promise<number[]>
const working = Promise.all([
gotoThen
]).catch(() => [123]);
// const broken: Promise<never[] | number[]>
const broken = Promise.all([
gotoCatch
]).catch(() => [456]);
// Promise { [ 123 ] } Promise { [ 456 ] }
console.log(working, broken);
Output
"use strict";
const gotoThen = Promise.resolve(123);
const gotoCatch = Promise.reject();
// const working: Promise<number[]>
const working = Promise.all([
gotoThen
]).catch(() => [123]);
// const broken: Promise<never[] | number[]>
const broken = Promise.all([
gotoCatch
]).catch(() => [456]);
// Promise { [ 123 ] } Promise { [ 456 ] }
console.log(working, broken);
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"useDefineForClassFields": false,
"alwaysStrict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"downlevelIteration": false,
"noEmitHelpers": false,
"noLib": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"esModuleInterop": true,
"preserveConstEnums": false,
"removeComments": false,
"skipLibCheck": false,
"checkJs": false,
"allowJs": false,
"declaration": true,
"experimentalDecorators": false,
"emitDecoratorMetadata": false,
"target": "ES2017",
"module": "ESNext"
}
}
Playground Link: Provided
TypeScript Version: 3.8.3
Search Terms:
Expected behavior:
brokenshould have the same type asworking.Actual behavior:
brokenhas an addednever[]type.Related Issues:
Code
Output
Compiler Options
{ "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "strictBindCallApply": true, "noImplicitThis": true, "noImplicitReturns": true, "useDefineForClassFields": false, "alwaysStrict": true, "allowUnreachableCode": false, "allowUnusedLabels": false, "downlevelIteration": false, "noEmitHelpers": false, "noLib": false, "noStrictGenericChecks": false, "noUnusedLocals": false, "noUnusedParameters": false, "esModuleInterop": true, "preserveConstEnums": false, "removeComments": false, "skipLibCheck": false, "checkJs": false, "allowJs": false, "declaration": true, "experimentalDecorators": false, "emitDecoratorMetadata": false, "target": "ES2017", "module": "ESNext" } }Playground Link: Provided