|
| 1 | +=== tests/cases/compiler/computedTypesKeyofNoIndexSignatureType.ts === |
| 2 | +type Compute<A> = { [K in keyof A]: Compute<A[K]>; } & {}; |
| 3 | +>Compute : Symbol(Compute, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 0)) |
| 4 | +>A : Symbol(A, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 13)) |
| 5 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 21)) |
| 6 | +>A : Symbol(A, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 13)) |
| 7 | +>Compute : Symbol(Compute, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 0)) |
| 8 | +>A : Symbol(A, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 13)) |
| 9 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 21)) |
| 10 | + |
| 11 | +type EqualsTest<T> = <A>() => A extends T ? 1 : 0; |
| 12 | +>EqualsTest : Symbol(EqualsTest, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 58)) |
| 13 | +>T : Symbol(T, Decl(computedTypesKeyofNoIndexSignatureType.ts, 2, 16)) |
| 14 | +>A : Symbol(A, Decl(computedTypesKeyofNoIndexSignatureType.ts, 2, 22)) |
| 15 | +>A : Symbol(A, Decl(computedTypesKeyofNoIndexSignatureType.ts, 2, 22)) |
| 16 | +>T : Symbol(T, Decl(computedTypesKeyofNoIndexSignatureType.ts, 2, 16)) |
| 17 | + |
| 18 | +type Equals<A1, A2> = EqualsTest<A2> extends EqualsTest<A1> ? 1 : 0; |
| 19 | +>Equals : Symbol(Equals, Decl(computedTypesKeyofNoIndexSignatureType.ts, 2, 50)) |
| 20 | +>A1 : Symbol(A1, Decl(computedTypesKeyofNoIndexSignatureType.ts, 3, 12)) |
| 21 | +>A2 : Symbol(A2, Decl(computedTypesKeyofNoIndexSignatureType.ts, 3, 15)) |
| 22 | +>EqualsTest : Symbol(EqualsTest, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 58)) |
| 23 | +>A2 : Symbol(A2, Decl(computedTypesKeyofNoIndexSignatureType.ts, 3, 15)) |
| 24 | +>EqualsTest : Symbol(EqualsTest, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 58)) |
| 25 | +>A1 : Symbol(A1, Decl(computedTypesKeyofNoIndexSignatureType.ts, 3, 12)) |
| 26 | + |
| 27 | +type Filter<K, I> = Equals<K, I> extends 1 ? never : K; |
| 28 | +>Filter : Symbol(Filter, Decl(computedTypesKeyofNoIndexSignatureType.ts, 3, 68)) |
| 29 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 5, 12)) |
| 30 | +>I : Symbol(I, Decl(computedTypesKeyofNoIndexSignatureType.ts, 5, 14)) |
| 31 | +>Equals : Symbol(Equals, Decl(computedTypesKeyofNoIndexSignatureType.ts, 2, 50)) |
| 32 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 5, 12)) |
| 33 | +>I : Symbol(I, Decl(computedTypesKeyofNoIndexSignatureType.ts, 5, 14)) |
| 34 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 5, 12)) |
| 35 | + |
| 36 | +type OmitIndex<T, I extends string | number> = { |
| 37 | +>OmitIndex : Symbol(OmitIndex, Decl(computedTypesKeyofNoIndexSignatureType.ts, 5, 55)) |
| 38 | +>T : Symbol(T, Decl(computedTypesKeyofNoIndexSignatureType.ts, 7, 15)) |
| 39 | +>I : Symbol(I, Decl(computedTypesKeyofNoIndexSignatureType.ts, 7, 17)) |
| 40 | + |
| 41 | + [K in keyof T as Filter<K, I>]: T[K]; |
| 42 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 8, 3)) |
| 43 | +>T : Symbol(T, Decl(computedTypesKeyofNoIndexSignatureType.ts, 7, 15)) |
| 44 | +>Filter : Symbol(Filter, Decl(computedTypesKeyofNoIndexSignatureType.ts, 3, 68)) |
| 45 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 8, 3)) |
| 46 | +>I : Symbol(I, Decl(computedTypesKeyofNoIndexSignatureType.ts, 7, 17)) |
| 47 | +>T : Symbol(T, Decl(computedTypesKeyofNoIndexSignatureType.ts, 7, 15)) |
| 48 | +>K : Symbol(K, Decl(computedTypesKeyofNoIndexSignatureType.ts, 8, 3)) |
| 49 | + |
| 50 | +}; |
| 51 | + |
| 52 | +type IndexObject = { [key: string]: unknown; }; |
| 53 | +>IndexObject : Symbol(IndexObject, Decl(computedTypesKeyofNoIndexSignatureType.ts, 9, 2)) |
| 54 | +>key : Symbol(key, Decl(computedTypesKeyofNoIndexSignatureType.ts, 11, 22)) |
| 55 | + |
| 56 | +type FooBar = { foo: "hello"; bar: "world"; }; |
| 57 | +>FooBar : Symbol(FooBar, Decl(computedTypesKeyofNoIndexSignatureType.ts, 11, 47)) |
| 58 | +>foo : Symbol(foo, Decl(computedTypesKeyofNoIndexSignatureType.ts, 12, 15)) |
| 59 | +>bar : Symbol(bar, Decl(computedTypesKeyofNoIndexSignatureType.ts, 12, 29)) |
| 60 | + |
| 61 | +type WithIndex = Compute<FooBar & IndexObject>; // { [x: string]: {}; foo: "hello"; bar: "world"; } <-- OK |
| 62 | +>WithIndex : Symbol(WithIndex, Decl(computedTypesKeyofNoIndexSignatureType.ts, 12, 46)) |
| 63 | +>Compute : Symbol(Compute, Decl(computedTypesKeyofNoIndexSignatureType.ts, 0, 0)) |
| 64 | +>FooBar : Symbol(FooBar, Decl(computedTypesKeyofNoIndexSignatureType.ts, 11, 47)) |
| 65 | +>IndexObject : Symbol(IndexObject, Decl(computedTypesKeyofNoIndexSignatureType.ts, 9, 2)) |
| 66 | + |
| 67 | +type WithoutIndex = OmitIndex<WithIndex, string>; // { foo: "hello"; bar: "world"; } <-- OK |
| 68 | +>WithoutIndex : Symbol(WithoutIndex, Decl(computedTypesKeyofNoIndexSignatureType.ts, 14, 47)) |
| 69 | +>OmitIndex : Symbol(OmitIndex, Decl(computedTypesKeyofNoIndexSignatureType.ts, 5, 55)) |
| 70 | +>WithIndex : Symbol(WithIndex, Decl(computedTypesKeyofNoIndexSignatureType.ts, 12, 46)) |
| 71 | + |
| 72 | +type FooBarKey = keyof FooBar; // "foo" | "bar" <-- OK |
| 73 | +>FooBarKey : Symbol(FooBarKey, Decl(computedTypesKeyofNoIndexSignatureType.ts, 15, 49)) |
| 74 | +>FooBar : Symbol(FooBar, Decl(computedTypesKeyofNoIndexSignatureType.ts, 11, 47)) |
| 75 | + |
| 76 | +type WithIndexKey = keyof WithIndex; // string | number <-- Expected: string |
| 77 | +>WithIndexKey : Symbol(WithIndexKey, Decl(computedTypesKeyofNoIndexSignatureType.ts, 17, 30)) |
| 78 | +>WithIndex : Symbol(WithIndex, Decl(computedTypesKeyofNoIndexSignatureType.ts, 12, 46)) |
| 79 | + |
| 80 | +type WithoutIndexKey = keyof WithoutIndex; // number <-- Expected: "foo" | "bar" |
| 81 | +>WithoutIndexKey : Symbol(WithoutIndexKey, Decl(computedTypesKeyofNoIndexSignatureType.ts, 18, 36)) |
| 82 | +>WithoutIndex : Symbol(WithoutIndex, Decl(computedTypesKeyofNoIndexSignatureType.ts, 14, 47)) |
| 83 | + |
0 commit comments