Skip to content

Commit

Permalink
fix(propfunctionprops): prevent 'undefined', 'null', 'never' conversi…
Browse files Browse the repository at this point in the history
…on to PropFnInterface

fix QwikDev#4946
  • Loading branch information
maiieul committed Oct 27, 2023
1 parent ac60661 commit 55484f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/docs/src/routes/api/qwik/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@
}
],
"kind": "TypeAlias",
"content": "```typescript\nexport type PropFunctionProps<PROPS extends {}> = {\n [K in keyof PROPS]: NonNullable<PROPS[K]> extends (...args: infer ARGS) => infer RET ? PropFnInterface<ARGS, Awaited<RET>> : PROPS[K];\n};\n```\n**References:** [PropFnInterface](#propfninterface)",
"content": "```typescript\nexport type PropFunctionProps<PROPS extends {}> = {\n [K in keyof PROPS]: PROPS[K] extends null | undefined | never ? PROPS[K] : NonNullable<PROPS[K]> extends (...args: infer ARGS) => infer RET ? PropFnInterface<ARGS, Awaited<RET>> : PROPS[K];\n};\n```\n**References:** [PropFnInterface](#propfninterface)",
"editUrl": "https://github.com/BuilderIO/qwik/tree/main/packages/qwik/src/core/component/component.public.ts",
"mdFile": "qwik.propfunctionprops.md"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/src/routes/api/qwik/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2123,9 +2123,9 @@ export type PropFunction<T extends Function = (...args: any[]) => any> =
```typescript
export type PropFunctionProps<PROPS extends {}> = {
[K in keyof PROPS]: NonNullable<PROPS[K]> extends (
...args: infer ARGS
) => infer RET
[K in keyof PROPS]: PROPS[K] extends null | undefined | never
? PROPS[K]
: NonNullable<PROPS[K]> extends (...args: infer ARGS) => infer RET
? PropFnInterface<ARGS, Awaited<RET>>
: PROPS[K];
};
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ export type PropFunction<T extends Function = (...args: any[]) => any> = T exten

// @public (undocumented)
export type PropFunctionProps<PROPS extends {}> = {
[K in keyof PROPS]: NonNullable<PROPS[K]> extends (...args: infer ARGS) => infer RET ? PropFnInterface<ARGS, Awaited<RET>> : PROPS[K];
[K in keyof PROPS]: PROPS[K] extends null | undefined | never ? PROPS[K] : NonNullable<PROPS[K]> extends (...args: infer ARGS) => infer RET ? PropFnInterface<ARGS, Awaited<RET>> : PROPS[K];
};

// @public
Expand Down
4 changes: 3 additions & 1 deletion packages/qwik/src/core/component/component.public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ export const isQwikComponent = (component: any): component is Component<any> =>

/** @public */
export type PropFunctionProps<PROPS extends {}> = {
[K in keyof PROPS]: NonNullable<PROPS[K]> extends (...args: infer ARGS) => infer RET
[K in keyof PROPS]: PROPS[K] extends null | undefined | never
? PROPS[K]
: NonNullable<PROPS[K]> extends (...args: infer ARGS) => infer RET
? PropFnInterface<ARGS, Awaited<RET>>
: PROPS[K];
};
Expand Down

0 comments on commit 55484f7

Please sign in to comment.