Why does a Typescript type conditional on `T extends undefined`, with T instantiated with `boolean`, resolve T to `never`?

As written, type OptionalArgBroken<Arg> = Arg extends undefined ? () => void : (arg: Arg) => void; is a distributive conditional type because the type being checked, Arg, is a naked generic type parameter. “Distributive” means that if the Arg passed in is a union, then the type will be evaluated for each member of … Read more

Typescript: Type of a property dependent on another property within the same object

I think what you are actually looking for is a discriminated union. IObject should itself be a union: export type IObject = { type: “checked” parameters: IParametersCheck } | { type: “counter” parameters: IParametersCounter } export type ObjectType = IObject[‘type’] //// in case you need this union export type ObjectParameters = IObject[‘parameters’] //// in case … Read more