Skip to content

Conversation

@zemlanin
Copy link
Contributor

@zemlanin zemlanin commented Nov 14, 2025

  • Originally, I've tried E extends HTMLElement = HTMLElement, but that made the new type arg effectively required because of Type 'RefObject<HTMLElement>' is not assignable to type 'Ref<HTMLDivElement>'.
  • src/App.tsx should passes type check without changes in this PR, but adding the new type arg seemed like a correct thing to do in the example

- Originally, `E` was `extends HTMLElement = HTMLElement`, but that made the new type arg effectively requred because of `Type 'RefObject<HTMLElement>' is not assignable to type 'Ref<HTMLDivElement>'.`
- `src/App.tsx` should passes type check without changes in this commit, but adding the new type arg seemed like a correct thing to do in the example
@xavi160
Copy link
Contributor

xavi160 commented Dec 10, 2025

Hi, thank you for the PR.
I’m wondering whether this change is actually necessary or if it’s solving a real issue.
My main concern with the proposed approach is that it doesn’t support react-native, where HTMLElements aren’t available at all.

@zemlanin
Copy link
Contributor Author

I’m wondering whether this change is actually necessary or if it’s solving a real issue.

We’re trying to eliminate as much any from our code base as possible, and using a type arg seems like a clean way of doing that from the caller side

My main concern with the proposed approach is that it doesn’t support react-native, where HTMLElements aren’t available at all.

Riiight. Removing extends HTMLElement would solve that concern, wouldn’t it?

(I don’t know if there’s an another approach of typing things like that in a way that would work in both react-dom and react-native)

@xavi160
Copy link
Contributor

xavi160 commented Dec 10, 2025

Riiight. Removing extends HTMLElement would solve that concern, wouldn’t it?

Yep. Just adding the generic type and defaulting it to any should do the trick for you

@zemlanin
Copy link
Contributor Author

zemlanin commented Dec 10, 2025

Yep. Just adding the generic type and defaulting it to any should do the trick for you

32bc04f + 9dcbf26

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants