mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Add regression tests
This commit is contained in:
@@ -22,3 +22,42 @@ type tup = [number, number, number, number];
|
||||
function foo(arg: Circular<tup>): tup {
|
||||
return arg;
|
||||
}
|
||||
|
||||
// Repro from #29442
|
||||
|
||||
type DeepMap<T extends unknown[], R> = {
|
||||
[K in keyof T]: T[K] extends unknown[] ? DeepMap<T[K], R> : R;
|
||||
};
|
||||
|
||||
type tpl = [string, [string, [string]]];
|
||||
type arr = string[][];
|
||||
|
||||
type t1 = DeepMap<tpl, number>; // [number, [number, [number]]]
|
||||
type t2 = DeepMap<arr, number>; // number[][]
|
||||
|
||||
// Repro from #29577
|
||||
|
||||
type Transform<T> = { [K in keyof T]: Transform<T[K]> };
|
||||
|
||||
interface User {
|
||||
avatar: string;
|
||||
}
|
||||
|
||||
interface Guest {
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
interface Product {
|
||||
users: (User | Guest)[];
|
||||
}
|
||||
|
||||
declare var product: Transform<Product>;
|
||||
product.users; // (Transform<User> | Transform<Guest>)[]
|
||||
|
||||
// Repro from #29702
|
||||
|
||||
type Remap1<T> = { [P in keyof T]: Remap1<T[P]>; };
|
||||
type Remap2<T> = T extends object ? { [P in keyof T]: Remap2<T[P]>; } : T;
|
||||
|
||||
type a = Remap1<string[]>; // string[]
|
||||
type b = Remap2<string[]>; // string[]
|
||||
|
||||
Reference in New Issue
Block a user