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

fix(jsx-qwik-attributes): fix ts error TS4023 #5722

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 31 additions & 3 deletions packages/docs/src/routes/api/qwik/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@
}
],
"kind": "Interface",
"content": "```typescript\nexport interface HTMLAttributes<E extends Element> extends HTMLElementAttrs, DOMAttributes<E> \n```\n**Extends:** HTMLElementAttrs, [DOMAttributes](#domattributes)<!-- -->&lt;E&gt;",
"content": "```typescript\nexport interface HTMLAttributes<E extends Element> extends HTMLElementAttrs, DOMAttributes<E> \n```\n**Extends:** [HTMLElementAttrs](#htmlelementattrs)<!-- -->, [DOMAttributes](#domattributes)<!-- -->&lt;E&gt;",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts",
"mdFile": "qwik.htmlattributes.md"
},
Expand All @@ -971,6 +971,20 @@
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts",
"mdFile": "qwik.htmlcrossoriginattribute.md"
},
{
"name": "HTMLElementAttrs",
"id": "htmlelementattrs",
"hierarchy": [
{
"name": "HTMLElementAttrs",
"id": "htmlelementattrs"
}
],
"kind": "Interface",
"content": "```typescript\nexport interface HTMLElementAttrs extends HTMLAttributesBase, FilterBase<HTMLElement> \n```\n**Extends:** HTMLAttributesBase, FilterBase&lt;HTMLElement&gt;",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts",
"mdFile": "qwik.htmlelementattrs.md"
},
{
"name": "HTMLFragment",
"id": "htmlfragment",
Expand Down Expand Up @@ -1898,6 +1912,20 @@
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-qwik-events.ts",
"mdFile": "qwik.qwikanimationevent.md"
},
{
"name": "QwikAttributes",
"id": "qwikattributes",
"hierarchy": [
{
"name": "QwikAttributes",
"id": "qwikattributes"
}
],
"kind": "Interface",
"content": "The Qwik DOM attributes without plain handlers, for use as function parameters\n\n\n```typescript\nexport interface QwikAttributes<EL extends Element> extends QwikAttributesBase, RefAttr<EL>, QwikEvents<EL, false> \n```\n**Extends:** QwikAttributesBase, RefAttr&lt;EL&gt;, QwikEvents&lt;EL, false&gt;\n\n\n| Property | Modifiers | Type | Description |\n| --- | --- | --- | --- |\n| [class?](#) | | [ClassList](#classlist) \\| undefined | _(Optional)_ |",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-qwik-attributes.ts",
"mdFile": "qwik.qwikattributes.md"
},
{
"name": "QwikChangeEvent",
"id": "qwikchangeevent",
Expand Down Expand Up @@ -1992,7 +2020,7 @@
}
],
"kind": "TypeAlias",
"content": "The DOM props without plain handlers, for use inside functions\n\n\n```typescript\nexport type QwikHTMLElements = {\n [tag in keyof HTMLElementTagNameMap]: Augmented<HTMLElementTagNameMap[tag], SpecialAttrs[tag]> & HTMLElementAttrs & QwikAttributes<HTMLElementTagNameMap[tag]>;\n};\n```",
"content": "The DOM props without plain handlers, for use inside functions\n\n\n```typescript\nexport type QwikHTMLElements = {\n [tag in keyof HTMLElementTagNameMap]: Augmented<HTMLElementTagNameMap[tag], SpecialAttrs[tag]> & HTMLElementAttrs & QwikAttributes<HTMLElementTagNameMap[tag]>;\n};\n```\n**References:** [HTMLElementAttrs](#htmlelementattrs)<!-- -->, [QwikAttributes](#qwikattributes)",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts",
"mdFile": "qwik.qwikhtmlelements.md"
},
Expand Down Expand Up @@ -2776,7 +2804,7 @@
}
],
"kind": "Interface",
"content": "```typescript\nexport interface SVGProps<T extends Element> extends SVGAttributes, QwikAttributes<T> \n```\n**Extends:** [SVGAttributes](#svgattributes)<!-- -->, QwikAttributes&lt;T&gt;",
"content": "```typescript\nexport interface SVGProps<T extends Element> extends SVGAttributes, QwikAttributes<T> \n```\n**Extends:** [SVGAttributes](#svgattributes)<!-- -->, [QwikAttributes](#qwikattributes)<!-- -->&lt;T&gt;",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts",
"mdFile": "qwik.svgprops.md"
},
Expand Down
32 changes: 30 additions & 2 deletions packages/docs/src/routes/api/qwik/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ export type HTMLAttributeReferrerPolicy = ReferrerPolicy;
export interface HTMLAttributes<E extends Element> extends HTMLElementAttrs, DOMAttributes<E>
```

**Extends:** HTMLElementAttrs, [DOMAttributes](#domattributes)&lt;E&gt;
**Extends:** [HTMLElementAttrs](#htmlelementattrs), [DOMAttributes](#domattributes)&lt;E&gt;

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts)

Expand All @@ -998,6 +998,16 @@ export type HTMLCrossOriginAttribute =

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts)

## HTMLElementAttrs

```typescript
export interface HTMLElementAttrs extends HTMLAttributesBase, FilterBase<HTMLElement>
```

**Extends:** HTMLAttributesBase, FilterBase&lt;HTMLElement&gt;

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts)

## HTMLFragment

```typescript
Expand Down Expand Up @@ -1935,6 +1945,22 @@ export type QwikAnimationEvent<T = Element> = NativeAnimationEvent;

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-qwik-events.ts)

## QwikAttributes

The Qwik DOM attributes without plain handlers, for use as function parameters

```typescript
export interface QwikAttributes<EL extends Element> extends QwikAttributesBase, RefAttr<EL>, QwikEvents<EL, false>
```

**Extends:** QwikAttributesBase, RefAttr&lt;EL&gt;, QwikEvents&lt;EL, false&gt;

| Property | Modifiers | Type | Description |
| ----------- | --------- | ------------------------------------ | ------------ |
| [class?](#) | | [ClassList](#classlist) \| undefined | _(Optional)_ |

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-qwik-attributes.ts)

## QwikChangeEvent

> Warning: This API is now obsolete.
Expand Down Expand Up @@ -2028,6 +2054,8 @@ export type QwikHTMLElements = {
};
```

**References:** [HTMLElementAttrs](#htmlelementattrs), [QwikAttributes](#qwikattributes)

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts)

## QwikIdleEvent
Expand Down Expand Up @@ -3039,7 +3067,7 @@ export interface SVGAttributes<T extends Element = Element> extends AriaAttribut
export interface SVGProps<T extends Element> extends SVGAttributes, QwikAttributes<T>
```

**Extends:** [SVGAttributes](#svgattributes), QwikAttributes&lt;T&gt;
**Extends:** [SVGAttributes](#svgattributes), [QwikAttributes](#qwikattributes)&lt;T&gt;

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-generated.ts)

Expand Down
17 changes: 13 additions & 4 deletions packages/qwik/src/core/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,20 @@ export type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top'
// @public (undocumented)
export type HTMLAttributeReferrerPolicy = ReferrerPolicy;

// Warning: (ae-forgotten-export) The symbol "HTMLElementAttrs" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export interface HTMLAttributes<E extends Element> extends HTMLElementAttrs, DOMAttributes<E> {
}

// @public (undocumented)
export type HTMLCrossOriginAttribute = 'anonymous' | 'use-credentials' | '' | undefined;

// Warning: (ae-forgotten-export) The symbol "HTMLAttributesBase" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "FilterBase" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export interface HTMLElementAttrs extends HTMLAttributesBase, FilterBase<HTMLElement> {
}

// @public (undocumented)
export const HTMLFragment: FunctionComponent<{
dangerouslySetInnerHTML: string;
Expand Down Expand Up @@ -681,6 +686,12 @@ export interface QuoteHTMLAttributes<T extends Element> extends Attrs<'q', T> {
// @public @deprecated (undocumented)
export type QwikAnimationEvent<T = Element> = NativeAnimationEvent;

// @public
export interface QwikAttributes<EL extends Element> extends QwikAttributesBase, RefAttr<EL>, QwikEvents<EL, false> {
// (undocumented)
class?: ClassList | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @maiieul @wmertens, is there any reason why Signal<ClassList> wasn't included here or should it be part of it? I'm not 100% sure what the original issue is related to and if it was an explicit decision to remove this here or not.

My current use case of using e.g. const ComponentProps = QwikIntrinsicElements<'img'> & {...additional stuff...} to create an image-like now sees this definition over the one with Signal<ClassList> from DOMAttributes.

Happy to put up a PR addressing this if unintended.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the signal is deprecated actually, because it makes it very hard to forward a class by doing class={[props.class, "hi"]}.

Instead, you should just pass classSignal.value and the optimizer will forward it for you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see, thank you! i thought i had seen something around that but couldn't find it when searching yesterday.

}

// @public @deprecated (undocumented)
export type QwikChangeEvent<T = Element> = Event;

Expand All @@ -700,8 +711,6 @@ export type QwikDragEvent<T = Element> = NativeDragEvent;
// @public @deprecated (undocumented)
export type QwikFocusEvent<T = Element> = NativeFocusEvent;

// Warning: (ae-forgotten-export) The symbol "QwikAttributes" needs to be exported by the entry point index.d.ts
//
// @public
export type QwikHTMLElements = {
[tag in keyof HTMLElementTagNameMap]: Augmented<HTMLElementTagNameMap[tag], SpecialAttrs[tag]> & HTMLElementAttrs & QwikAttributes<HTMLElementTagNameMap[tag]>;
Expand Down
1 change: 1 addition & 0 deletions packages/qwik/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export { Fragment, HTMLFragment, RenderOnce, jsx, jsxDEV, jsxs } from './render/
export type * from './render/jsx/types/jsx-generated';
export type {
DOMAttributes,
QwikAttributes,
JSXTagName,
JSXChildren,
ComponentBaseProps,
Expand Down
3 changes: 2 additions & 1 deletion packages/qwik/src/core/render/jsx/types/jsx-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ interface HTMLAttributesBase extends AriaAttributes {
popover?: 'manual' | 'auto' | undefined;
}

interface HTMLElementAttrs extends HTMLAttributesBase, FilterBase<HTMLElement> {}
/** @public */
export interface HTMLElementAttrs extends HTMLAttributesBase, FilterBase<HTMLElement> {}

/** @public */
export interface HTMLAttributes<E extends Element> extends HTMLElementAttrs, DOMAttributes<E> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export interface DOMAttributes<EL extends Element>
class?: ClassList | Signal<ClassList> | undefined;
}

/** The Qwik DOM attributes without plain handlers, for use as function parameters */
/** The Qwik DOM attributes without plain handlers, for use as function parameters @public */
export interface QwikAttributes<EL extends Element>
extends QwikAttributesBase,
RefAttr<EL>,
Expand Down