-
Couldn't load subscription status.
- Fork 13.1k
Closed
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Description
TypeScript Version: 1.8.10 and 2.0.0 beta
Code
function getPromise(): Promise<string> {
return new Promise(resolve => {
resolve(1234); // Should fail as 'abcd' is not a number
});
}
getPromise().then(s => {
console.log(s.length);
});Expected behaviour: A compile error on line 3
Actual behaviour: The program prints undefined
If I copy the type definition of resolve from the interface PromiseConstructor (in lib.es6.d.ts), I get the expected behaviour:
function getPromise(): Promise<string> {
return new Promise((resolve: (value?: string | PromiseLike<string>) => void) => {
resolve(1234); // As expected I get an error
// TS2345: Argument of type 'number' is not assignable to parameter of type 'string | PromiseLike<string>' Type 'number' is not assignable to type 'PromiseLike<string>'.
});
}
getPromise().then(s => {
console.log(s.length);
});Metadata
Metadata
Assignees
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.