File: awaitedTypeStrictNull.symbols

package info (click to toggle)
node-typescript 5.1.6%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 492,516 kB
  • sloc: javascript: 2,078,951; makefile: 6; sh: 1
file content (241 lines) | stat: -rw-r--r-- 14,465 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
=== tests/cases/compiler/awaitedTypeStrictNull.ts ===
type T1 = Awaited<number>;
>T1 : Symbol(T1, Decl(awaitedTypeStrictNull.ts, 0, 0))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))

type T2 = Awaited<Promise<number>>;
>T2 : Symbol(T2, Decl(awaitedTypeStrictNull.ts, 0, 26))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

type T3 = Awaited<number | Promise<number>>;
>T3 : Symbol(T3, Decl(awaitedTypeStrictNull.ts, 1, 35))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

type T4 = Awaited<number | Promise<string>>;
>T4 : Symbol(T4, Decl(awaitedTypeStrictNull.ts, 2, 44))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

type T5 = Awaited<{ then: number }>;
>T5 : Symbol(T5, Decl(awaitedTypeStrictNull.ts, 3, 44))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>then : Symbol(then, Decl(awaitedTypeStrictNull.ts, 4, 19))

type T6 = Awaited<{ then(): void }>; // never (non-promise "thenable")
>T6 : Symbol(T6, Decl(awaitedTypeStrictNull.ts, 4, 36))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>then : Symbol(then, Decl(awaitedTypeStrictNull.ts, 5, 19))

type T7 = Awaited<{ then(x: number): void }>; // never (non-promise "thenable")
>T7 : Symbol(T7, Decl(awaitedTypeStrictNull.ts, 5, 36))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>then : Symbol(then, Decl(awaitedTypeStrictNull.ts, 6, 19))
>x : Symbol(x, Decl(awaitedTypeStrictNull.ts, 6, 25))

type T8 = Awaited<{ then(x: () => void): void }>; // unknown
>T8 : Symbol(T8, Decl(awaitedTypeStrictNull.ts, 6, 45))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>then : Symbol(then, Decl(awaitedTypeStrictNull.ts, 7, 19))
>x : Symbol(x, Decl(awaitedTypeStrictNull.ts, 7, 25))

type T9 = Awaited<any>;
>T9 : Symbol(T9, Decl(awaitedTypeStrictNull.ts, 7, 49))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))

type T10 = Awaited<never>;
>T10 : Symbol(T10, Decl(awaitedTypeStrictNull.ts, 8, 23))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))

type T11 = Awaited<unknown>;
>T11 : Symbol(T11, Decl(awaitedTypeStrictNull.ts, 9, 26))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))

type T12 = Awaited<Promise<Promise<number>>>;
>T12 : Symbol(T12, Decl(awaitedTypeStrictNull.ts, 10, 28))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

type T13 = _Expect<Awaited<Promise<Promise<number>> | string | null>, /*expected*/ string | number | null>; // otherwise just prints T13 in types tests, which isn't very helpful
>T13 : Symbol(T13, Decl(awaitedTypeStrictNull.ts, 11, 45))
>_Expect : Symbol(_Expect, Decl(awaitedTypeStrictNull.ts, 61, 1))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

type T14 = _Expect<Awaited<Promise<Promise<number>> | string | undefined>, /*expected*/ string | number | undefined>; // otherwise just prints T14 in types tests, which isn't very helpful
>T14 : Symbol(T14, Decl(awaitedTypeStrictNull.ts, 12, 107))
>_Expect : Symbol(_Expect, Decl(awaitedTypeStrictNull.ts, 61, 1))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

type T15 = _Expect<Awaited<Promise<Promise<number>> | string | null | undefined>, /*expected*/ string | number | null | undefined>; // otherwise just prints T15 in types tests, which isn't very helpful
>T15 : Symbol(T15, Decl(awaitedTypeStrictNull.ts, 13, 117))
>_Expect : Symbol(_Expect, Decl(awaitedTypeStrictNull.ts, 61, 1))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))

type TUndefined = Awaited<undefined>;
>TUndefined : Symbol(TUndefined, Decl(awaitedTypeStrictNull.ts, 14, 131))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))

type TNull = Awaited<null>;
>TNull : Symbol(TNull, Decl(awaitedTypeStrictNull.ts, 16, 37))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))

type TNullOrUndefined = Awaited<null | undefined>;
>TNullOrUndefined : Symbol(TNullOrUndefined, Decl(awaitedTypeStrictNull.ts, 17, 27))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))

interface BadPromise { then(cb: (value: BadPromise) => void): void; }
>BadPromise : Symbol(BadPromise, Decl(awaitedTypeStrictNull.ts, 18, 50))
>then : Symbol(BadPromise.then, Decl(awaitedTypeStrictNull.ts, 20, 22))
>cb : Symbol(cb, Decl(awaitedTypeStrictNull.ts, 20, 28))
>value : Symbol(value, Decl(awaitedTypeStrictNull.ts, 20, 33))
>BadPromise : Symbol(BadPromise, Decl(awaitedTypeStrictNull.ts, 18, 50))

type T16 = Awaited<BadPromise>; // error
>T16 : Symbol(T16, Decl(awaitedTypeStrictNull.ts, 20, 69))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>BadPromise : Symbol(BadPromise, Decl(awaitedTypeStrictNull.ts, 18, 50))

interface BadPromise1 { then(cb: (value: BadPromise2) => void): void; }
>BadPromise1 : Symbol(BadPromise1, Decl(awaitedTypeStrictNull.ts, 21, 31))
>then : Symbol(BadPromise1.then, Decl(awaitedTypeStrictNull.ts, 23, 23))
>cb : Symbol(cb, Decl(awaitedTypeStrictNull.ts, 23, 29))
>value : Symbol(value, Decl(awaitedTypeStrictNull.ts, 23, 34))
>BadPromise2 : Symbol(BadPromise2, Decl(awaitedTypeStrictNull.ts, 23, 71))

interface BadPromise2 { then(cb: (value: BadPromise1) => void): void; }
>BadPromise2 : Symbol(BadPromise2, Decl(awaitedTypeStrictNull.ts, 23, 71))
>then : Symbol(BadPromise2.then, Decl(awaitedTypeStrictNull.ts, 24, 23))
>cb : Symbol(cb, Decl(awaitedTypeStrictNull.ts, 24, 29))
>value : Symbol(value, Decl(awaitedTypeStrictNull.ts, 24, 34))
>BadPromise1 : Symbol(BadPromise1, Decl(awaitedTypeStrictNull.ts, 21, 31))

type T17 = Awaited<BadPromise1>; // error
>T17 : Symbol(T17, Decl(awaitedTypeStrictNull.ts, 24, 71))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>BadPromise1 : Symbol(BadPromise1, Decl(awaitedTypeStrictNull.ts, 21, 31))

// https://github.com/microsoft/TypeScript/issues/46934
type T18 = Awaited<{ then(cb: (value: number, other: { }) => void)}>; // number
>T18 : Symbol(T18, Decl(awaitedTypeStrictNull.ts, 25, 32))
>Awaited : Symbol(Awaited, Decl(lib.es5.d.ts, --, --))
>then : Symbol(then, Decl(awaitedTypeStrictNull.ts, 28, 20))
>cb : Symbol(cb, Decl(awaitedTypeStrictNull.ts, 28, 26))
>value : Symbol(value, Decl(awaitedTypeStrictNull.ts, 28, 31))
>other : Symbol(other, Decl(awaitedTypeStrictNull.ts, 28, 45))

// https://github.com/microsoft/TypeScript/issues/33562
type MaybePromise<T> = T | Promise<T> | PromiseLike<T>
>MaybePromise : Symbol(MaybePromise, Decl(awaitedTypeStrictNull.ts, 31, 54), Decl(awaitedTypeStrictNull.ts, 28, 69))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 31, 18))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 31, 18))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 31, 18))
>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 31, 18))

declare function MaybePromise<T>(value: T): MaybePromise<T>;
>MaybePromise : Symbol(MaybePromise, Decl(awaitedTypeStrictNull.ts, 31, 54), Decl(awaitedTypeStrictNull.ts, 28, 69))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 32, 30))
>value : Symbol(value, Decl(awaitedTypeStrictNull.ts, 32, 33))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 32, 30))
>MaybePromise : Symbol(MaybePromise, Decl(awaitedTypeStrictNull.ts, 31, 54), Decl(awaitedTypeStrictNull.ts, 28, 69))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 32, 30))

async function main() {
>main : Symbol(main, Decl(awaitedTypeStrictNull.ts, 32, 60))

    let aaa: number;
>aaa : Symbol(aaa, Decl(awaitedTypeStrictNull.ts, 35, 7))

    let bbb: string;
>bbb : Symbol(bbb, Decl(awaitedTypeStrictNull.ts, 36, 7))

    [
        aaa,
>aaa : Symbol(aaa, Decl(awaitedTypeStrictNull.ts, 35, 7))

        bbb,
>bbb : Symbol(bbb, Decl(awaitedTypeStrictNull.ts, 36, 7))

    ] = await Promise.all([
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))

        MaybePromise(1),
>MaybePromise : Symbol(MaybePromise, Decl(awaitedTypeStrictNull.ts, 31, 54), Decl(awaitedTypeStrictNull.ts, 28, 69))

        MaybePromise('2'),
>MaybePromise : Symbol(MaybePromise, Decl(awaitedTypeStrictNull.ts, 31, 54), Decl(awaitedTypeStrictNull.ts, 28, 69))

        MaybePromise(true),
>MaybePromise : Symbol(MaybePromise, Decl(awaitedTypeStrictNull.ts, 31, 54), Decl(awaitedTypeStrictNull.ts, 28, 69))

    ])
}

// https://github.com/microsoft/TypeScript/issues/45924
class Api<D = {}> {
>Api : Symbol(Api, Decl(awaitedTypeStrictNull.ts, 45, 1))
>D : Symbol(D, Decl(awaitedTypeStrictNull.ts, 48, 10))

	// Should result in `Promise<T>` instead of `Promise<Awaited<T>>`.
	async post<T = D>() { return this.request<T>(); }
>post : Symbol(Api.post, Decl(awaitedTypeStrictNull.ts, 48, 19))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 50, 12))
>D : Symbol(D, Decl(awaitedTypeStrictNull.ts, 48, 10))
>this.request : Symbol(Api.request, Decl(awaitedTypeStrictNull.ts, 50, 50))
>this : Symbol(Api, Decl(awaitedTypeStrictNull.ts, 45, 1))
>request : Symbol(Api.request, Decl(awaitedTypeStrictNull.ts, 50, 50))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 50, 12))

	async request<D>(): Promise<D> { throw new Error(); }
>request : Symbol(Api.request, Decl(awaitedTypeStrictNull.ts, 50, 50))
>D : Symbol(D, Decl(awaitedTypeStrictNull.ts, 51, 15))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>D : Symbol(D, Decl(awaitedTypeStrictNull.ts, 51, 15))
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
}

declare const api: Api;
>api : Symbol(api, Decl(awaitedTypeStrictNull.ts, 54, 13))
>Api : Symbol(Api, Decl(awaitedTypeStrictNull.ts, 45, 1))

interface Obj { x: number }
>Obj : Symbol(Obj, Decl(awaitedTypeStrictNull.ts, 54, 23))
>x : Symbol(Obj.x, Decl(awaitedTypeStrictNull.ts, 55, 15))

async function fn<T>(): Promise<T extends object ? { [K in keyof T]: Obj } : Obj> {
>fn : Symbol(fn, Decl(awaitedTypeStrictNull.ts, 55, 27))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 57, 18))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 57, 18))
>K : Symbol(K, Decl(awaitedTypeStrictNull.ts, 57, 54))
>T : Symbol(T, Decl(awaitedTypeStrictNull.ts, 57, 18))
>Obj : Symbol(Obj, Decl(awaitedTypeStrictNull.ts, 54, 23))
>Obj : Symbol(Obj, Decl(awaitedTypeStrictNull.ts, 54, 23))

	// Per #45924, this was failing due to incorrect inference both above and here.
	// Should not error.
	return api.post();
>api.post : Symbol(Api.post, Decl(awaitedTypeStrictNull.ts, 48, 19))
>api : Symbol(api, Decl(awaitedTypeStrictNull.ts, 54, 13))
>post : Symbol(Api.post, Decl(awaitedTypeStrictNull.ts, 48, 19))
}

// helps with tests where '.types' just prints out the type alias name
type _Expect<TActual extends TExpected, TExpected> = TActual;
>_Expect : Symbol(_Expect, Decl(awaitedTypeStrictNull.ts, 61, 1))
>TActual : Symbol(TActual, Decl(awaitedTypeStrictNull.ts, 64, 13))
>TExpected : Symbol(TExpected, Decl(awaitedTypeStrictNull.ts, 64, 39))
>TExpected : Symbol(TExpected, Decl(awaitedTypeStrictNull.ts, 64, 39))
>TActual : Symbol(TActual, Decl(awaitedTypeStrictNull.ts, 64, 13))