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): remove Promise from FC #5730

Merged
merged 1 commit into from
Jan 18, 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
14 changes: 7 additions & 7 deletions packages/docs/src/routes/api/qwik/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@
}
],
"kind": "Interface",
"content": "The Qwik-specific attributes that DOM elements accept\n\n\n```typescript\nexport interface DOMAttributes<EL extends Element> extends QwikAttributesBase, RefAttr<EL>, QwikEvents<EL> \n```\n**Extends:** QwikAttributesBase, RefAttr&lt;EL&gt;, QwikEvents&lt;EL&gt;\n\n\n| Property | Modifiers | Type | Description |\n| --- | --- | --- | --- |\n| [class?](#) | | [ClassList](#classlist) \\| [Signal](#signal)<!-- -->&lt;[ClassList](#classlist)<!-- -->&gt; \\| undefined | _(Optional)_ |",
"content": "The Qwik-specific attributes that DOM elements accept\n\n\n```typescript\nexport interface DOMAttributes<EL extends Element> extends DOMAttributesBase<EL>, QwikEvents<EL> \n```\n**Extends:** DOMAttributesBase&lt;EL&gt;, QwikEvents&lt;EL&gt;\n\n\n| Property | Modifiers | Type | Description |\n| --- | --- | --- | --- |\n| [class?](#) | | [ClassList](#classlist) \\| [Signal](#signal)<!-- -->&lt;[ClassList](#classlist)<!-- -->&gt; \\| undefined | _(Optional)_ |",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-qwik-attributes.ts",
"mdFile": "qwik.domattributes.md"
},
Expand Down Expand Up @@ -705,7 +705,7 @@
}
],
"kind": "Interface",
"content": "```typescript\ninterface ElementChildrenAttribute \n```\n\n\n| Property | Modifiers | Type | Description |\n| --- | --- | --- | --- |\n| [children](#) | | any | |",
"content": "```typescript\ninterface ElementChildrenAttribute \n```\n\n\n| Property | Modifiers | Type | Description |\n| --- | --- | --- | --- |\n| [children](#) | | [JSXChildren](#jsxchildren) | |",
"mdFile": "qwik.qwikjsx.elementchildrenattribute.md"
},
{
Expand Down Expand Up @@ -847,7 +847,7 @@
}
],
"kind": "TypeAlias",
"content": "Any sync or async function that returns JSXOutput.\n\nNote that this includes QRLs.\n\nThe `key`<!-- -->, `flags` and `dev` parameters are for internal use.\n\n\n```typescript\nexport type FunctionComponent<P extends Record<any, any> = Record<any, unknown>> = {\n renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput | Promise<JSXOutput>;\n}['renderFn'];\n```\n**References:** [DevJSX](#devjsx)<!-- -->, [JSXOutput](#jsxoutput)",
"content": "Any function taking a props object that returns JSXOutput.\n\nThe `key`<!-- -->, `flags` and `dev` parameters are for internal use.\n\n\n```typescript\nexport type FunctionComponent<P = unknown> = {\n renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput;\n}['renderFn'];\n```\n**References:** [DevJSX](#devjsx)<!-- -->, [JSXOutput](#jsxoutput)",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-node.ts",
"mdFile": "qwik.functioncomponent.md"
},
Expand Down Expand Up @@ -1158,7 +1158,7 @@
}
],
"kind": "Variable",
"content": "```typescript\njsx: <T extends string | FunctionComponent<any>>(type: T, props: T extends FunctionComponent<infer PROPS extends Record<any, any>> ? PROPS : Record<any, unknown>, key?: string | number | null) => JSXNode<T>\n```",
"content": "```typescript\njsx: <T extends string | FunctionComponent<any>>(type: T, props: T extends FunctionComponent<infer PROPS> ? PROPS : Record<any, unknown>, key?: string | number | null) => JSXNode<T>\n```",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/jsx-runtime.ts",
"mdFile": "qwik.jsx.md"
},
Expand Down Expand Up @@ -1186,7 +1186,7 @@
}
],
"kind": "Variable",
"content": "```typescript\njsxDEV: <T extends string | FunctionComponent>(type: T, props: T extends FunctionComponent<infer PROPS extends Record<any, any>> ? PROPS : Record<any, unknown>, key: string | number | null | undefined, _isStatic: boolean, opts: JsxDevOpts, _ctx: unknown) => JSXNode<T>\n```",
"content": "```typescript\njsxDEV: <T extends string | FunctionComponent<Record<any, unknown>>>(type: T, props: T extends FunctionComponent<infer PROPS> ? PROPS : Record<any, unknown>, key: string | number | null | undefined, _isStatic: boolean, opts: JsxDevOpts, _ctx: unknown) => JSXNode<T>\n```",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/jsx-runtime.ts",
"mdFile": "qwik.jsxdev.md"
},
Expand All @@ -1200,7 +1200,7 @@
}
],
"kind": "Interface",
"content": "A JSX Node, an internal structure. You probably want to use `JSXOutput` instead.\n\n\n```typescript\nexport interface JSXNode<T extends string | FunctionComponent | unknown = unknown> \n```\n\n\n| Property | Modifiers | Type | Description |\n| --- | --- | --- | --- |\n| [children](#) | | [JSXChildren](#jsxchildren) \\| null | |\n| [dev?](#) | | [DevJSX](#devjsx) | _(Optional)_ |\n| [flags](#) | | number | |\n| [immutableProps](#) | | Record&lt;any, unknown&gt; \\| null | |\n| [key](#) | | string \\| null | |\n| [props](#) | | T extends [FunctionComponent](#functioncomponent)<!-- -->&lt;infer B&gt; ? B : Record&lt;any, unknown&gt; | |\n| [type](#) | | T | |",
"content": "A JSX Node, an internal structure. You probably want to use `JSXOutput` instead.\n\n\n```typescript\nexport interface JSXNode<T extends string | FunctionComponent | unknown = unknown> \n```\n\n\n| Property | Modifiers | Type | Description |\n| --- | --- | --- | --- |\n| [children](#) | | [JSXChildren](#jsxchildren) \\| null | |\n| [dev?](#) | | [DevJSX](#devjsx) | _(Optional)_ |\n| [flags](#) | | number | |\n| [immutableProps](#) | | Record&lt;any, unknown&gt; \\| null | |\n| [key](#) | | string \\| null | |\n| [props](#) | | T extends [FunctionComponent](#functioncomponent)<!-- -->&lt;infer P&gt; ? P : Record&lt;any, unknown&gt; | |\n| [type](#) | | T | |",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-node.ts",
"mdFile": "qwik.jsxnode.md"
},
Expand Down Expand Up @@ -1886,7 +1886,7 @@
}
],
"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)_ |",
"content": "The Qwik DOM attributes without plain handlers, for use as function parameters\n\n\n```typescript\nexport interface QwikAttributes<EL extends Element> extends DOMAttributesBase<EL>, QwikEvents<EL, false> \n```\n**Extends:** DOMAttributesBase&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"
},
Expand Down
32 changes: 14 additions & 18 deletions packages/docs/src/routes/api/qwik/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,10 @@ export interface DialogHTMLAttributes<T extends Element> extends Attrs<'dialog',
The Qwik-specific attributes that DOM elements accept

```typescript
export interface DOMAttributes<EL extends Element> extends QwikAttributesBase, RefAttr<EL>, QwikEvents<EL>
export interface DOMAttributes<EL extends Element> extends DOMAttributesBase<EL>, QwikEvents<EL>
```

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

| Property | Modifiers | Type | Description |
| ----------- | --------- | ---------------------------------------------------------------------------------------- | ------------ |
Expand Down Expand Up @@ -771,9 +771,9 @@ type Element = JSXOutput;
interface ElementChildrenAttribute
```

| Property | Modifiers | Type | Description |
| ------------- | --------- | ---- | ----------- |
| [children](#) | | any | |
| Property | Modifiers | Type | Description |
| ------------- | --------- | --------------------------- | ----------- |
| [children](#) | | [JSXChildren](#jsxchildren) | |

## ElementType

Expand Down Expand Up @@ -866,22 +866,18 @@ Fragment: FunctionComponent<{

## FunctionComponent

Any sync or async function that returns JSXOutput.

Note that this includes QRLs.
Any function taking a props object that returns JSXOutput.

The `key`, `flags` and `dev` parameters are for internal use.

```typescript
export type FunctionComponent<
P extends Record<any, any> = Record<any, unknown>,
> = {
export type FunctionComponent<P = unknown> = {
renderFn(
props: P,
key: string | null,
flags: number,
dev?: DevJSX,
): JSXOutput | Promise<JSXOutput>;
): JSXOutput;
}["renderFn"];
```

Expand Down Expand Up @@ -1223,7 +1219,7 @@ isSignal: <T = unknown>(obj: any) => obj is Signal<T>
```typescript
jsx: <T extends string | FunctionComponent<any>>(
type: T,
props: T extends FunctionComponent<infer PROPS extends Record<any, any>>
props: T extends FunctionComponent<infer PROPS>
? PROPS
: Record<any, unknown>,
key?: string | number | null,
Expand Down Expand Up @@ -1256,9 +1252,9 @@ export type JSXChildren =
## jsxDEV

```typescript
jsxDEV: <T extends string | FunctionComponent>(
jsxDEV: <T extends string | FunctionComponent<Record<any, unknown>>>(
type: T,
props: T extends FunctionComponent<infer PROPS extends Record<any, any>>
props: T extends FunctionComponent<infer PROPS>
? PROPS
: Record<any, unknown>,
key: string | number | null | undefined,
Expand All @@ -1285,7 +1281,7 @@ export interface JSXNode<T extends string | FunctionComponent | unknown = unknow
| [flags](#) | | number | |
| [immutableProps](#) | | Record&lt;any, unknown&gt; \| null | |
| [key](#) | | string \| null | |
| [props](#) | | T extends [FunctionComponent](#functioncomponent)&lt;infer B&gt; ? B : Record&lt;any, unknown&gt; | |
| [props](#) | | T extends [FunctionComponent](#functioncomponent)&lt;infer P&gt; ? P : Record&lt;any, unknown&gt; | |
| [type](#) | | T | |

[Edit this section](https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/render/jsx/types/jsx-node.ts)
Expand Down Expand Up @@ -1936,10 +1932,10 @@ export type QwikAnimationEvent<T = Element> = NativeAnimationEvent;
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>
export interface QwikAttributes<EL extends Element> extends DOMAttributesBase<EL>, QwikEvents<EL, false>
```

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

| Property | Modifiers | Type | Description |
| ----------- | --------- | ------------------------------------ | ------------ |
Expand Down
Empty file modified packages/qwik/qwik-cli.cjs
100644 → 100755
Empty file.
21 changes: 10 additions & 11 deletions packages/qwik/src/core/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,11 @@ export interface DevJSX {
export interface DialogHTMLAttributes<T extends Element> extends Attrs<'dialog', T> {
}

// Warning: (ae-forgotten-export) The symbol "QwikAttributesBase" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "RefAttr" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "DOMAttributesBase" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QwikEvents" needs to be exported by the entry point index.d.ts
//
// @public
export interface DOMAttributes<EL extends Element> extends QwikAttributesBase, RefAttr<EL>, QwikEvents<EL> {
export interface DOMAttributes<EL extends Element> extends DOMAttributesBase<EL>, QwikEvents<EL> {
// (undocumented)
class?: ClassList | Signal<ClassList> | undefined;
}
Expand Down Expand Up @@ -247,8 +246,8 @@ export const Fragment: FunctionComponent<{
}>;

// @public
export type FunctionComponent<P extends Record<any, any> = Record<any, unknown>> = {
renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput | Promise<JSXOutput>;
export type FunctionComponent<P = unknown> = {
renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput;
}['renderFn'];

// @internal (undocumented)
Expand Down Expand Up @@ -394,7 +393,7 @@ export type IntrinsicSVGElements = {
export const isSignal: <T = unknown>(obj: any) => obj is Signal<T>;

// @public (undocumented)
const jsx: <T extends string | FunctionComponent<any>>(type: T, props: T extends FunctionComponent<infer PROPS extends Record<any, any>> ? PROPS : Record<any, unknown>, key?: string | number | null) => JSXNode<T>;
const jsx: <T extends string | FunctionComponent<any>>(type: T, props: T extends FunctionComponent<infer PROPS> ? PROPS : Record<any, unknown>, key?: string | number | null) => JSXNode<T>;
export { jsx }
export { jsx as jsxs }

Expand All @@ -404,13 +403,13 @@ export const _jsxBranch: <T>(input?: T | undefined) => T | undefined;
// Warning: (ae-forgotten-export) The symbol "JsxDevOpts" needs to be exported by the entry point index.d.ts
//
// @internal
export const _jsxC: <T extends string | FunctionComponent>(type: T, mutableProps: (T extends FunctionComponent<infer PROPS extends Record<any, any>> ? PROPS : Record<any, unknown>) | null, flags: number, key: string | number | null, dev?: JsxDevOpts) => JSXNode<T>;
export const _jsxC: <T extends string | FunctionComponent<Record<any, unknown>>>(type: T, mutableProps: (T extends FunctionComponent<infer PROPS> ? PROPS : Record<any, unknown>) | null, flags: number, key: string | number | null, dev?: JsxDevOpts) => JSXNode<T>;

// @public (undocumented)
export type JSXChildren = string | number | boolean | null | undefined | Function | RegExp | JSXChildren[] | Promise<JSXChildren> | Signal<JSXChildren> | JSXNode;

// @public (undocumented)
export const jsxDEV: <T extends string | FunctionComponent>(type: T, props: T extends FunctionComponent<infer PROPS extends Record<any, any>> ? PROPS : Record<any, unknown>, key: string | number | null | undefined, _isStatic: boolean, opts: JsxDevOpts, _ctx: unknown) => JSXNode<T>;
export const jsxDEV: <T extends string | FunctionComponent<Record<any, unknown>>>(type: T, props: T extends FunctionComponent<infer PROPS> ? PROPS : Record<any, unknown>, key: string | number | null | undefined, _isStatic: boolean, opts: JsxDevOpts, _ctx: unknown) => JSXNode<T>;

// @public
export interface JSXNode<T extends string | FunctionComponent | unknown = unknown> {
Expand All @@ -425,7 +424,7 @@ export interface JSXNode<T extends string | FunctionComponent | unknown = unknow
// (undocumented)
key: string | null;
// (undocumented)
props: T extends FunctionComponent<infer B> ? B : Record<any, unknown>;
props: T extends FunctionComponent<infer P> ? P : Record<any, unknown>;
// (undocumented)
type: T;
}
Expand Down Expand Up @@ -671,7 +670,7 @@ export interface QuoteHTMLAttributes<T extends Element> extends Attrs<'q', T> {
export type QwikAnimationEvent<T = Element> = NativeAnimationEvent;

// @public
export interface QwikAttributes<EL extends Element> extends QwikAttributesBase, RefAttr<EL>, QwikEvents<EL, false> {
export interface QwikAttributes<EL extends Element> extends DOMAttributesBase<EL>, QwikEvents<EL, false> {
// (undocumented)
class?: ClassList | undefined;
}
Expand Down Expand Up @@ -720,7 +719,7 @@ export namespace QwikJSX {
// (undocumented)
export interface ElementChildrenAttribute {
// (undocumented)
children: any;
children: JSXChildren;
}
// (undocumented)
export type ElementType = string | FunctionComponent<Record<any, any>>;
Expand Down
1 change: 1 addition & 0 deletions packages/qwik/src/core/component/component.public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type PropsOf<COMP> = COMP extends string
*
* @public
*/
// In reality, Component is a QRL but that makes the types too complex
export type Component<PROPS = unknown> = FunctionComponent<PublicProps<PROPS>>;

export type ComponentChildren<PROPS> = PROPS extends {
Expand Down
4 changes: 2 additions & 2 deletions packages/qwik/src/core/render/jsx/jsx-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const _jsxS = <T extends string>(
*
* Create a JSXNode for any tag, with possibly immutable props embedded in props
*/
export const _jsxC = <T extends string | FunctionComponent>(
export const _jsxC = <T extends string | FunctionComponent<Record<any, unknown>>>(
type: T,
mutableProps: (T extends FunctionComponent<infer PROPS> ? PROPS : Record<any, unknown>) | null,
flags: number,
Expand Down Expand Up @@ -367,7 +367,7 @@ export const HTMLFragment: FunctionComponent<{ dangerouslySetInnerHTML: string }
jsx(Virtual, props);

/** @public */
export const jsxDEV = <T extends string | FunctionComponent>(
export const jsxDEV = <T extends string | FunctionComponent<Record<any, unknown>>>(
type: T,
props: T extends FunctionComponent<infer PROPS> ? PROPS : Record<any, unknown>,
key: string | number | null | undefined,
Expand Down
15 changes: 4 additions & 11 deletions packages/qwik/src/core/render/jsx/types/jsx-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ import type { JSXChildren } from './jsx-qwik-attributes';
export type JSXOutput = JSXNode | string | number | boolean | null | undefined | JSXOutput[];

/**
* Any sync or async function that returns JSXOutput.
*
* Note that this includes QRLs.
* Any function taking a props object that returns JSXOutput.
*
* The `key`, `flags` and `dev` parameters are for internal use.
*
* @public
*/
export type FunctionComponent<P extends Record<any, any> = Record<any, unknown>> = {
renderFn(
props: P,
key: string | null,
flags: number,
dev?: DevJSX
): JSXOutput | Promise<JSXOutput>;
export type FunctionComponent<P = unknown> = {
renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput;
}['renderFn'];

/** @public */
Expand All @@ -40,7 +33,7 @@ export interface DevJSX {
*/
export interface JSXNode<T extends string | FunctionComponent | unknown = unknown> {
type: T;
props: T extends FunctionComponent<infer B> ? B : Record<any, unknown>;
props: T extends FunctionComponent<infer P> ? P : Record<any, unknown>;
immutableProps: Record<any, unknown> | null;
children: JSXChildren | null;
flags: number;
Expand Down
18 changes: 10 additions & 8 deletions packages/qwik/src/core/render/jsx/types/jsx-qwik-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ export type JSXChildren =
| Signal<JSXChildren>
| JSXNode;

interface QwikAttributesBase extends PreventDefault {
/** @public */
export interface QwikIntrinsicAttributes {
key?: string | number | null | undefined;
dangerouslySetInnerHTML?: string | undefined;
children?: JSXChildren;

/** Corresponding slot name used to project the element into. */
Expand All @@ -251,19 +251,21 @@ type RefFnInterface<EL> = {
interface RefAttr<EL extends Element> {
ref?: Ref<EL> | undefined;
}
interface DOMAttributesBase<EL extends Element>
extends QwikIntrinsicAttributes,
PreventDefault,
RefAttr<EL> {
dangerouslySetInnerHTML?: string | undefined;
}

/** The Qwik-specific attributes that DOM elements accept @public */
export interface DOMAttributes<EL extends Element>
extends QwikAttributesBase,
RefAttr<EL>,
QwikEvents<EL> {
export interface DOMAttributes<EL extends Element> extends DOMAttributesBase<EL>, QwikEvents<EL> {
class?: ClassList | Signal<ClassList> | undefined;
}

/** The Qwik DOM attributes without plain handlers, for use as function parameters @public */
export interface QwikAttributes<EL extends Element>
extends QwikAttributesBase,
RefAttr<EL>,
extends DOMAttributesBase<EL>,
QwikEvents<EL, false> {
class?: ClassList | undefined;
}