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
|
//// [inferTypeConstraintInstantiationCircularity.ts]
type AMappedType<T> = { [KeyType in keyof T]: number };
type HasM = {
m: number;
};
// Simplified repro from #48059
interface X1<
T extends HasM,
Output = AMappedType<{ s: number; } & { [k in keyof T]: number; }>
> {
tee: T;
output: Output;
}
type F1<T> = T extends X1<infer U> ? U : never;
// With default inlined
interface X2<
T extends HasM,
Output
> {
tee: T;
output: Output;
}
type F2<T> = T extends X2<infer U, AMappedType<{ s: number; } & { [k in keyof (infer U)]: number; }>> ? U : never;
// Original repro
type Simplify<T> = {[KeyType in keyof T]: T[KeyType]};
type optionalKeys<T extends object> = {
[k in keyof T]: undefined extends T[k] ? k : never;
}[keyof T];
type requiredKeys<T extends object> = Exclude<keyof T, optionalKeys<T>>;
export type addQuestionMarks<T extends object> = {
[k in optionalKeys<T>]?: T[k];
} & {
[k in requiredKeys<T>]: T[k];
};
type ZodRawShape = {
[k: string]: ZodType<any>;
};
interface ZodType<Output> {
_type: Output;
}
interface ZodObject<
T extends ZodRawShape,
Output = Simplify<
{
[k in optionalKeys<T>]?: T[k];
} & {
[k in requiredKeys<T>]: T[k];
}
>
> extends ZodType<Output> {
readonly _shape: T;
}
type MyObject<T> = T extends ZodObject<infer U>
? U extends ZodRawShape
? U
: never
: never;
// Repro from #50479
type Cell<Value extends BaseValue = any, BaseValue = unknown> = {
id: string
}
type Items<Type extends Cell = Cell> = {
type: Type
name: string
}
type InferIOItemToJSType<T extends Items> =
T extends { type: infer U }
? U extends Cell<infer V/**, infer _ or unknown, or any valid type **/>
? V
: never
: never
//// [inferTypeConstraintInstantiationCircularity.js]
"use strict";
exports.__esModule = true;
|