Conversation
|
|
||
| function getTypeOfFirstParameterOfSignature(signature: Signature) { | ||
| return getTypeAtPosition(signature, 0); | ||
| return getTypeWithFacts(getTypeAtPosition(signature, 0), TypeFacts.NEUndefined); |
There was a problem hiding this comment.
this function is used in two places
- when we get type of first parameter in the call signature of
then - when we get type of first parameter in the
onFulfilledcallback.
Do we want to strip undefined in both places or just in the first one?
There was a problem hiding this comment.
well. i went back and forth on this, and then did not see a reason why not...
so we want to get T
then<U>(success?: (value: T) => U,...): IPromise<U>
the first takes care of the optionality of succes?, the second would remove the undefined if value was optional. the question is what is the promised type for this:
then<U>(success?: (value?: T) => U,...): IPromise<U>
is it T or T|undefined ?
There was a problem hiding this comment.
what about cases like this:
declare function resolve1<T>(value: T): Promise<T>;
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
async function f(x?: number) {
let x1 = await resolve1(x);
let x2 = await resolve2(x);
}Currently type of x1 is number | undefined and x2 fails with error addressed by this PR.
With the fix type of x2 will be just number which will be inconsistent with type for x1
There was a problem hiding this comment.
good point. fixed. thanks
|
👍 |
Fixes #8423