Question:
Consider the following components:Basic.tsx
Extended.tsx
Basic.tsx
) type to equal whatever type is passed into it in Extended.tsx
. i.e. onPropertySelect
in Basic should know the type to use is (property: BasicPropertyDetails<ExtendedPropertyDetails>) => void
(based on the value in Extended.tsx
).Note: The type of
property
inside onPropertySelect
will have the same subtype as BasicPropertyDetails<unknown>
As of now I cannot get the above to work and the implementation (or the return tsx) in Extended throws an error for types not matching.
Answer:
InExtended.tsx
, pass type T
to onPropertySelect
property.If you have better answer, please add a comment about this, thank you!