Skip to content

Commit 9ff66fb

Browse files
committed
Code review comments
1 parent b4baee4 commit 9ff66fb

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13428,7 +13428,7 @@ namespace ts {
1342813428
return undefined;
1342913429
}
1343013430

13431-
const onfulfilledParameterType = getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature));
13431+
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
1343213432
if (onfulfilledParameterType.flags & TypeFlags.Any) {
1343313433
return undefined;
1343413434
}
@@ -13443,7 +13443,7 @@ namespace ts {
1344313443
}
1344413444

1344513445
function getTypeOfFirstParameterOfSignature(signature: Signature) {
13446-
return getTypeWithFacts(getTypeAtPosition(signature, 0), TypeFacts.NEUndefined);
13446+
return getTypeAtPosition(signature, 0);
1344713447
}
1344813448

1344913449
/**

tests/baselines/reference/asyncFunctionsAndStrictNullChecks.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ declare namespace Windows.Foundation {
1515
async function sample(promise: Windows.Foundation.IPromise<number>) {
1616
var number = await promise;
1717
}
18+
19+
20+
declare function resolve1<T>(value: T): Promise<T>;
21+
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
22+
23+
async function sample2(x?: number) {
24+
let x1 = await resolve1(x);
25+
let x2 = await resolve2(x);
26+
}
1827

1928

2029
//// [asyncFunctionsAndStrictNullChecks.js]
@@ -31,3 +40,9 @@ function sample(promise) {
3140
var number = yield promise;
3241
});
3342
}
43+
function sample2(x) {
44+
return __awaiter(this, void 0, void 0, function* () {
45+
let x1 = yield resolve1(x);
46+
let x2 = yield resolve2(x);
47+
});
48+
}

tests/baselines/reference/asyncFunctionsAndStrictNullChecks.symbols

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,37 @@ async function sample(promise: Windows.Foundation.IPromise<number>) {
100100
>promise : Symbol(promise, Decl(asyncFunctionsAndStrictNullChecks.ts, 13, 22))
101101
}
102102

103+
104+
declare function resolve1<T>(value: T): Promise<T>;
105+
>resolve1 : Symbol(resolve1, Decl(asyncFunctionsAndStrictNullChecks.ts, 15, 1))
106+
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26))
107+
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 29))
108+
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26))
109+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
110+
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 26))
111+
112+
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
113+
>resolve2 : Symbol(resolve2, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 51))
114+
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 26))
115+
>value : Symbol(value, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 29))
116+
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 26))
117+
>Windows : Symbol(Windows, Decl(asyncFunctionsAndStrictNullChecks.ts, 0, 0))
118+
>Foundation : Symbol(Windows.Foundation, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 26))
119+
>IPromise : Symbol(Windows.Foundation.IPromise, Decl(asyncFunctionsAndStrictNullChecks.ts, 1, 38))
120+
>T : Symbol(T, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 26))
121+
122+
async function sample2(x?: number) {
123+
>sample2 : Symbol(sample2, Decl(asyncFunctionsAndStrictNullChecks.ts, 19, 71))
124+
>x : Symbol(x, Decl(asyncFunctionsAndStrictNullChecks.ts, 21, 23))
125+
126+
let x1 = await resolve1(x);
127+
>x1 : Symbol(x1, Decl(asyncFunctionsAndStrictNullChecks.ts, 22, 7))
128+
>resolve1 : Symbol(resolve1, Decl(asyncFunctionsAndStrictNullChecks.ts, 15, 1))
129+
>x : Symbol(x, Decl(asyncFunctionsAndStrictNullChecks.ts, 21, 23))
130+
131+
let x2 = await resolve2(x);
132+
>x2 : Symbol(x2, Decl(asyncFunctionsAndStrictNullChecks.ts, 23, 7))
133+
>resolve2 : Symbol(resolve2, Decl(asyncFunctionsAndStrictNullChecks.ts, 18, 51))
134+
>x : Symbol(x, Decl(asyncFunctionsAndStrictNullChecks.ts, 21, 23))
135+
}
136+

tests/baselines/reference/asyncFunctionsAndStrictNullChecks.types

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,41 @@ async function sample(promise: Windows.Foundation.IPromise<number>) {
101101
>promise : Windows.Foundation.IPromise<number>
102102
}
103103

104+
105+
declare function resolve1<T>(value: T): Promise<T>;
106+
>resolve1 : <T>(value: T) => Promise<T>
107+
>T : T
108+
>value : T
109+
>T : T
110+
>Promise : Promise<T>
111+
>T : T
112+
113+
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
114+
>resolve2 : <T>(value: T) => Windows.Foundation.IPromise<T>
115+
>T : T
116+
>value : T
117+
>T : T
118+
>Windows : any
119+
>Foundation : any
120+
>IPromise : Windows.Foundation.IPromise<TResult>
121+
>T : T
122+
123+
async function sample2(x?: number) {
124+
>sample2 : (x?: number | undefined) => Promise<void>
125+
>x : number | undefined
126+
127+
let x1 = await resolve1(x);
128+
>x1 : number | undefined
129+
>await resolve1(x) : number | undefined
130+
>resolve1(x) : Promise<number | undefined>
131+
>resolve1 : <T>(value: T) => Promise<T>
132+
>x : number | undefined
133+
134+
let x2 = await resolve2(x);
135+
>x2 : number | undefined
136+
>await resolve2(x) : number | undefined
137+
>resolve2(x) : Windows.Foundation.IPromise<number | undefined>
138+
>resolve2 : <T>(value: T) => Windows.Foundation.IPromise<T>
139+
>x : number | undefined
140+
}
141+

tests/cases/compiler/asyncFunctionsAndStrictNullChecks.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ declare namespace Windows.Foundation {
1616
async function sample(promise: Windows.Foundation.IPromise<number>) {
1717
var number = await promise;
1818
}
19+
20+
21+
declare function resolve1<T>(value: T): Promise<T>;
22+
declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
23+
24+
async function sample2(x?: number) {
25+
let x1 = await resolve1(x);
26+
let x2 = await resolve2(x);
27+
}

0 commit comments

Comments
 (0)