Skip to content

Commit 6262ac8

Browse files
committed
Add tests
1 parent 44ada08 commit 6262ac8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// @strict: true
2+
3+
// Both of the following types trigger the recursion limiter in getImmediateBaseConstraint
4+
5+
type T1<B extends { [K in keyof B]: Extract<B[Exclude<keyof B, K>], { val: string }>["val"] }> = B;
6+
type T2<B extends { [K in keyof B]: B[Exclude<keyof B, K>]["val"] }> = B;
7+
8+
// Repros from #22950
9+
10+
type AProp<T extends { a: string }> = T
11+
12+
declare function myBug<
13+
T extends { [K in keyof T]: T[K] extends AProp<infer U> ? U : never }
14+
>(arg: T): T
15+
16+
const out = myBug({obj1: {a: "test"}})
17+
18+
type Value<V extends string = string> = Record<"val", V>;
19+
declare function value<V extends string>(val: V): Value<V>;
20+
21+
declare function ensureNoDuplicates<
22+
T extends {
23+
[K in keyof T]: Extract<T[K], Value>["val"] extends Extract<T[Exclude<keyof T, K>], Value>["val"]
24+
? never
25+
: any
26+
}
27+
>(vals: T): void;
28+
29+
const noError = ensureNoDuplicates({main: value("test"), alternate: value("test2")});
30+
31+
const shouldBeNoError = ensureNoDuplicates({main: value("test")});
32+
33+
const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")});

0 commit comments

Comments
 (0)