ElementType<P, Tag>: {
    [K in Tag]: P extends IntrinsicElements[K]
        ? K
        : never
}[Tag] | ComponentType<P>

Used to retrieve the possible components which accept a given set of props.

Can be passed no type parameters to get a union of all possible components and tags.

Is a superset of ComponentType.

Type Parameters

  • P = any

    The props to match against. If not passed, defaults to any.

  • Tag extends keyof IntrinsicElements = keyof IntrinsicElements

    An optional tag to match against. If not passed, attempts to match against all possible tags.

Example

// All components and tags (img, embed etc.)
// which accept `src`
type SrcComponents = ElementType<{ src: any }>;

Example

// All components
type AllComponents = ElementType;

Example

// All custom components which match `src`, and tags which
// match `src`, narrowed down to just `audio` and `embed`
type SrcComponents = ElementType<{ src: any }, 'audio' | 'embed'>;