Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sandersn opened this issue Apr 20, 2023 · 0 comments · Fixed by #53943
Closed

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

sandersn opened this issue Apr 20, 2023 · 0 comments · Fixed by #53943
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Recent Regression This is a new regression just found in the last major/minor version of TypeScript.

Comments

@sandersn
Copy link
Member

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.

@sandersn sandersn added Bug A bug in TypeScript Recent Regression This is a new regression just found in the last major/minor version of TypeScript. labels Apr 20, 2023
@sandersn sandersn added this to the TypeScript 5.1.0 milestone Apr 20, 2023
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Recent Regression This is a new regression just found in the last major/minor version of TypeScript.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants