Skip to content

JSX.ElementType from #51328 doesn't instantiate defaulted type parameters correctly #53939

Closed

Description

In DT, preact dependents like preact-i18n have failures in their tests when they should not:

preact-i18n-tests.tsx:26:13 - error TS2786: 'span' cannot be used as a JSX component.
  Its type '"span"' is not a valid JSX element type.

26     return <span>{test}</span>;

preact's ElementType looks like this:

	export type ElementType<P = any> =
		| {
				[K in keyof IntrinsicElements]: P extends IntrinsicElements[K]
					? K
					: never;
		  }[keyof IntrinsicElements]
		| ComponentType<P>;

Replacing P with any and deleting the type parameter fixes the problem:

	export type ElementType =
		| {
				[K in keyof IntrinsicElements]: any extends IntrinsicElements[K]
					? K
					: never;
		  }[keyof IntrinsicElements]
		| ComponentType<any>;

Broken by #51328. Looks like almost the right test case was added to catch this, but not quite.

Activity

  1. added
    Bug
    Recent Regression
    on Apr 20, 2023
  2. added
    Fix Available
    on Apr 20, 2023
  3. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugFix AvailableRecent Regression

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions