Skip to content

Promise.catch null vs null as null #44913

Closed
andrewbranch/typescript-go
#19
@bluelovers

Description

@bluelovers

Bug Report

🔎 Search Terms

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground link with relevant code

💻 Code

Version 4.4.0-dev.20210705

image

export function f1()
{
	return Promise.resolve(1).catch(e => null)
}

export function f2()
{
	return Promise.resolve(1).catch(e => null as null)
}

// @ts-expect-error
f1().then(v => v.split('')) // <====== should is `number` but `any`

// @ts-expect-error
f2().then(v => v.split(''))
{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2019",
    "jsx": "preserve",
    "moduleResolution": "node",
    "allowJs": false,
    "allowUmdGlobalAccess": false,
    "sourceMap": true,
    "inlineSourceMap": false,
    "inlineSources": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "strict": false,
    "strictBindCallApply": true,
    "strictNullChecks": false,
    "strictFunctionTypes": true,
    "noImplicitThis": true,
    "noImplicitOverride": true,
    "preserveConstEnums": true,
    "forceConsistentCasingInFileNames": true,
    "incremental": true,
    "noErrorTruncation": true,
    "removeComments": true,
    "traceResolution": false,
    "newLine": "lf",
    "esModuleInterop": true,
    "importHelpers": true
  }
}

🙁 Actual behavior

// @ts-expect-error
f1().then(v => v.split('')) // <====== should is `number` but `any`

🙂 Expected behavior

// @ts-expect-error
f1().then(v => v.split('')) // <====== should is `number`

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions