We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
I'm using TypeScript 1.6.3 in Visual Studio 2015. The es6-promise declaration I'm using contains:
declare class Promise<R> implements Thenable<R> { constructor(callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: any) => void) => void); then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>; }
The following works with an explicit typing of the Promise generic:
new Promise < { foo: number }>((resolve) => { resolve({ foo: 1 }); }).then((value) => { value.foo; });
However, shouldn't type inference allow the following to work?
new Promise((resolve) => { resolve({ foo: 1 }); }).then((value) => { value.foo; });
Instead, I am getting an error when accessing value.foo that foo does not exist on type '{}'. Why is TypeScript defaulting to the {} type?
{}
I'm using TypeScript 1.6.3 in Visual Studio 2015. The es6-promise declaration I'm using contains:
The following works with an explicit typing of the Promise generic:
However, shouldn't type inference allow the following to work?
Instead, I am getting an error when accessing value.foo that foo does not exist on type '{}'. Why is TypeScript defaulting to the
{}type?