Open
Description
π Search Terms
"promise", "then", "null", "undefined", "nullable"
π Version & Regression Information
- This changed between versions 3.33.3333 and 3.5.1
β― Playground Link
π» Code
// Your code here
π Actual behavior
// Let a promise that will resolve to 0;
const p = Promise.resolve(0);
// This should error but compiler says it is fine
function p3(): Promise<string> {
return p.then(null);
}
// I can basically claim that this function returns anything
function p4(): Promise<Window | Date | URL | { anything: "really" }> {
return p.then(null);
}
// This should also error but compiler says it is fine
function p5(): Promise<string> {
return p.then(undefined);
}
π Expected behavior
// Let a promise that will resolve to 0;
const p = Promise.resolve(0);
// This should error with:
// Type 'number' is not assignable to type 'string'.
function p3(): Promise<string> {
return p.then(null);
}
// This should error with:
// Type 'number' is not assignable to type 'string'.
function p5(): Promise<string> {
return p.then(undefined);
}