Understanding the Need for Variance Check on Higher-Kinded Types

I am trying to understand the need for the variance check on Higher-Kinded Types (https://www.effect.website/docs/behaviour/hkt#variance)

The docs report an example on the full Kind definition, but I was looking at the more simple example with only F:

type Kind<F extends TypeLambda, Target> = F extends {
  readonly type: unknown;
}
  ? (F & { readonly Target: Target })["type"]
  : {
      readonly F: F;
      // This enforces invariance
      readonly Target: (_: Target) => Target;
    };


In which situations the second branch { readonly F: F; readonly Target: (_: Target) => Target } is needed to prevent errors?

Could someone give me a concrete example where not having the invariance check causes problems?
A fully-fledged functional effect system for TypeScript with a rich standard library
Higher-Kinded Types – Effect
Was this page helpful?