qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[📖] Document how to extend JSX attributes. (Potential Feature Suggestion)

Open flmng0 opened this issue 2 years ago • 0 comments

Suggestion

Hello all.

I've seen this asked about multiple times in the Discord, and have yet to see an answer provided, so I thought this was the next best idea.


Many Vite plugins (see UnoCSS) add/change properties on HTML elements.

With TypeScript, errors are raised when an unknown attribute is found.

In other frameworks you can extend the JSX HTMLAttributes interface in a custom shims.d.ts or similar.

For example, in SolidJS, using UnoCSS preset-attributify:

import type { AttributifyAttributes } from '@unocss/preset-attributify'

declare module 'solid-js' {
  namespace JSX {
    interface HTMLAttributes<T> extends AttributifyAttributes {}
  }
}

I still haven't figured out how to do this in Qwik. I'm a noob when it comes to JSX internals though, so it could just be me.

My suggestion is that extending JSX attributes be clearly documented

(or if there is currently no support, add it; hence "Potential Feature Request")

Regards,

flmng0 avatar Jul 06 '23 01:07 flmng0