This (apparently valid) code compiled OK with TypeScript 2.0:
functionf(): Promise<void>{returnPromise.resolve(4).then((n: number)=>{if(n!==200){returnPromise.reject('error');}returnPromise.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:
functionf(n: number): Promise<void>{if(n!==200){returnPromise.reject('error');}returnPromise.resolve();}
This (apparently valid) code compiled OK with TypeScript 2.0:
With TypeScript 2.1.4 it gives:
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: