-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
This (apparently valid) code compiled OK with TypeScript 2.0:
function f(): Promise<void> {
return Promise.resolve(4).then((n: number) => {
if (n !== 200) {
return Promise.reject('error');
}
return Promise.resolve();
});
}
With TypeScript 2.1.4 it gives:
test.ts(2,10): error TS2322: Type 'Promise' is not assignable to type 'Promise'.
Type 'number' is not assignable to type 'void'.
tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"lib": ["es2015"]
}
}
It seems that the problem comes when promises are chained. For instance when removing the .then()
chain, compilation runs without any error:
function f(n: number): Promise<void> {
if (n !== 200) {
return Promise.reject('error');
}
return Promise.resolve();
}
mywhere, ognus, garthk, JustBlackBird and springuper
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue