@@ -47,6 +47,122 @@ tests/cases/compiler/awaitedType.ts(22,12): error TS2589: Type instantiation is
4747 ])
4848 }
4949
50+ // non-generic
51+ async function f1(x: string) {
52+ // y: string
53+ const y = await x;
54+ }
55+
56+ async function f2(x: unknown) {
57+ // y: unknown
58+ const y = await x;
59+ }
60+
61+ async function f3(x: object) {
62+ // y: object
63+ const y = await x;
64+ }
65+
66+ async function f4(x: Promise<string>) {
67+ // y: string
68+ const y = await x;
69+ }
70+
71+ async function f5(x: Promise<unknown>) {
72+ // y: unknown
73+ const y = await x;
74+ }
75+
76+ async function f6(x: Promise<object>) {
77+ // y: object
78+ const y = await x;
79+ }
80+
81+ // generic
82+
83+ async function f7<T>(x: T) {
84+ // NOTE: T does not belong solely to the domain of primitive types and either does
85+ // not have a base constraint, its base constraint is `any`, `unknown`, `{}`, or `object`,
86+ // or it has a non-primitive base constraint with a callable `then`.
87+
88+ // y: Awaited<T>
89+ const y = await x;
90+ }
91+
92+ async function f8<T extends any>(x: T) {
93+ // NOTE: T does not belong solely to the domain of primitive types and either does
94+ // not have a base constraint, its base constraint is `any`, `unknown`, `{}`, or `object`,
95+ // or it has a non-primitive base constraint with a callable `then`.
96+
97+ // y: Awaited<T>
98+ const y = await x;
99+ }
100+
101+ async function f9<T extends unknown>(x: T) {
102+ // NOTE: T does not belong solely to the domain of primitive types and either does
103+ // not have a base constraint, its base constraint is `any`, `unknown`, `{}`, or `object`,
104+ // or it has a non-primitive base constraint with a callable `then`.
105+
106+ // y: Awaited<T>
107+ const y = await x;
108+ }
109+
110+ async function f10<T extends {}>(x: T) {
111+ // NOTE: T does not belong solely to the domain of primitive types and either does
112+ // not have a base constraint, its base constraint is `any`, `unknown`, `{}`, or `object`,
113+ // or it has a non-primitive base constraint with a callable `then`.
114+
115+ // y: Awaited<T>
116+ const y = await x;
117+ }
118+
119+ async function f11<T extends { then(onfulfilled: (value: unknown) => void): void }>(x: T) {
120+ // NOTE: T does not belong solely to the domain of primitive types and either does
121+ // not have a base constraint, its base constraint is `any`, `unknown`, `{}`, or `object`,
122+ // or it has a non-primitive base constraint with a callable `then`.
123+
124+ // y: Awaited<T>
125+ const y = await x;
126+ }
127+
128+ async function f12<T extends string | object>(x: T) {
129+ // NOTE: T does not belong solely to the domain of primitive types and either does
130+ // not have a base constraint, its base constraint is `any`, `unknown`, `{}`, or `object`,
131+ // or it has a non-primitive base constraint with a callable `then`.
132+
133+ // y: Awaited<T>
134+ const y = await x;
135+ }
136+
137+ async function f13<T extends string>(x: T) {
138+ // NOTE: T belongs to the domain of primitive types
139+
140+ // y: T
141+ const y = await x;
142+ }
143+
144+ async function f14<T extends { x: number }>(x: T) {
145+ // NOTE: T has a non-primitive base constraint without a callable `then`.
146+
147+ // y: T
148+ const y = await x;
149+ }
150+
151+ async function f15<T extends { then: number }>(x: T) {
152+ // NOTE: T has a non-primitive base constraint without a callable `then`.
153+
154+ // y: T
155+ const y = await x;
156+ }
157+
158+ async function f16<T extends number & { then(): void }>(x: T) {
159+ // NOTE: T belongs to the domain of primitive types (regardless of `then`)
160+
161+ // y: T
162+ const y = await x;
163+ }
164+
165+
50166 // helps with tests where '.types' just prints out the type alias name
51167 type _Expect<TActual extends TExpected, TExpected> = TActual;
52168
0 commit comments