Skip to content

Adds A Generic El Type Parameter To Hooks Interfaces - #3961

Merged
SteffenDE merged 1 commit into
phoenixframework:mainfrom
IdoLeshkowitz:allow-passing-el-type-to-hooks
Aug 28, 2025
Merged

Adds A Generic El Type Parameter To Hooks Interfaces #3961
SteffenDE merged 1 commit into
phoenixframework:mainfrom
IdoLeshkowitz:allow-passing-el-type-to-hooks

Conversation

@IdoLeshkowitz

Copy link
Copy Markdown
Contributor

closes #3956

@IdoLeshkowitz
IdoLeshkowitz marked this pull request as ready for review August 24, 2025 09:10
@IdoLeshkowitz
IdoLeshkowitz marked this pull request as draft August 27, 2025 22:06
@IdoLeshkowitz
IdoLeshkowitz force-pushed the allow-passing-el-type-to-hooks branch from be51470 to 4664e8f Compare August 27, 2025 22:06
@IdoLeshkowitz
IdoLeshkowitz marked this pull request as ready for review August 27, 2025 22:06
@SteffenDE
SteffenDE merged commit 17ba97f into phoenixframework:main Aug 28, 2025
7 checks passed
@SteffenDE

Copy link
Copy Markdown
Member

Thank you :)

@vanderhoop

vanderhoop commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

What's the expected usage of this? I would have expected Hook<HTMLInputElement> to ensure that the el attribute would be typed as an HTMLInputElement, but on v1.1.9, typescript still reads it as the more generic HTMLElement. A changelog example would be helpful.

@SteffenDE

Copy link
Copy Markdown
Member

@vanderhoop Hook already had a first generic argument in case you wanted to type other methods or attributes yourself. So it should be Hook<object, HTMLInputElement> where instead of object you could also pass something more specific, like:

interface SpecificHook {
  customAttribute: string;
}

const specificHook: Hook<SpecificHook, HTMLInputElement> = {...};

@vanderhoop

Copy link
Copy Markdown
Contributor

thanks @SteffenDE! onward!

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.

[Proposal] - Add Generic Element Type Support to Hook Interface

3 participants