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

Namespace 'React' has no exported member 'HTMLProps' #4114

Closed
jschuler opened this issue Aug 23, 2023 · 3 comments · Fixed by #4117
Closed

Namespace 'React' has no exported member 'HTMLProps' #4114

jschuler opened this issue Aug 23, 2023 · 3 comments · Fixed by #4117

Comments

@jschuler
Copy link

Describe the bug
I have a react/typescript project that I am migrating to preact+preact/compat.

Many of our existing library components extend React.HTMLProps, for example:

import * as React from 'react';
export interface BadgeProps extends React.HTMLProps<HTMLSpanElement> {
  isRead: boolean;
}

After aliasing react to use preact/compat, it complains that Namespace 'React' has no exported member 'HTMLProps'.

Workaround for me is to update the component file

import { JSX } from 'preact';

export interface BadgeProps extends JSX.HTMLAttributes<HTMLSpanElement> {
  ...
}

Expected behavior
What should have happened when following the steps above?

I would have expected HTMLProps to exist in preact/compat so that I don't have to change hundreds of component files.

@rschristian
Copy link
Member

rschristian commented Aug 24, 2023

I would have expected HTMLProps to exist in preact/compat so that I don't have to change hundreds of component files.

You can patch the types yourself in the meantime, no need for batch renaming:

// global.d.ts
import * as preact from 'preact';

declare module 'react' {
  export interface HTMLProps<T> extends preact.JSX.HTMLAttributes<T> {}
}

@ynwd
Copy link

ynwd commented Sep 12, 2023

@rschristian
Copy link
Member

Please open a new issue (or PR, if you're willing) for that.

It's impossible to track issues listed as replies to already closed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants