preactjs / preact-www

:book: Preact documentation website.
https://preactjs.com
MIT License
358 stars 500 forks source link

TypeScript: Add docs on extending `IntrinsicElements` & `HTMLAttributes` #1145

Closed rschristian closed 3 months ago

rschristian commented 4 months ago

People often need to create global attrs or types for custom elements and, at the moment, that usually means slogging through issues to find the right config. We should document this better.

ngdangtu-vn commented 4 months ago

One case is Lume and its inline plugin:

image

rschristian commented 3 months ago

@ngdangtu-vn If you have a couple minutes, I'd love to know your thoughts on https://deploy-preview-1151--preactjs.netlify.app/guide/v10/typescript#extending-built-in-jsx-types

Is there anything missing that you'd like to see? Would this have been useful to you? Is it clear enough how to use?

ngdangtu-vn commented 3 months ago

Thanks, it looks very clear. It would be even more detail if we can add example on specific HTML element though. Like attributes for specific elements, such as input, link, meta etc.

rschristian commented 3 months ago

I don't think that's something Preact's types support at the moment -- we don't differentiate attributes by element type, there's HTMLAttributes (which applies to all elements) and only that.

There's a couple issues relating to this (like https://github.com/preactjs/preact/issues/4202) but there hasn't yet been any contributions providing this.

ngdangtu-vn commented 3 months ago

I see, that's pity but I think this is already very good for type hint atm. I believe many people will appreciate this doc.