import { FC } from 'react';
type Test<X extends string> = X;
const a: Test<'a'> = {} as Test<'a' | 'b'>;
console.log(a);
type TestFn<X extends string> = (args: X) => void;
const b: TestFn<'a'> = {} as TestFn<'a' | 'b'>;
console.log(b);
type TestFC<X extends string> = FC<{ data: X }>;
const c: TestFC<'a'> = {} as TestFC<'a' | 'b'>;
console.log(c);
const a introduce a type error, which is a desired behaviour because 'a'|'b' is not a subtype of 'a', however, if the type parameter is present in place of the function parameter, there is no error because the parameter is contravariant instead of covariant, TS is smart enough to identify the pattern even in place of generic
However, TS is not smart enough to handle const c: TestFC<'a'> = {} as TestFC<'a' | 'b'>; correctly, it reports a undesired error Type '"a" | "b"' is not assignable to type '"a"'. the root case should be TS fail to notice {data:X} present in function paramter
const aintroduce a type error, which is a desired behaviour because 'a'|'b' is not a subtype of 'a', however, if the type parameter is present in place of the function parameter, there is no error because the parameter is contravariant instead of covariant, TS is smart enough to identify the pattern even in place of genericHowever, TS is not smart enough to handle
const c: TestFC<'a'> = {} as TestFC<'a' | 'b'>;correctly, it reports a undesired errorType '"a" | "b"' is not assignable to type '"a"'.the root case should be TS fail to notice {data:X} present in function paramter