Skip to content

Commit

Permalink
WithLifecycle parameters was generating non-optional types. fixed tha…
Browse files Browse the repository at this point in the history
…t by explicitly typing WithLifecycle
  • Loading branch information
DeepDoge committed Dec 20, 2024
1 parent 4a642f3 commit 26243bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,14 @@ export type WithLifecycle<T extends HTMLElement> = T & {
effect(callback: Lifecycle.OnConnected<T>): Lifecycle.OffConnected
}

export let WithLifecycle = <T extends keyof HTMLElementTagNameMap>(
export let WithLifecycle: <T extends keyof HTMLElementTagNameMap>(
tagName: T,
newTagName?: `${string}-${string}`
) => { new (): WithLifecycle<HTMLElementTagNameMap[T]> } = <
T extends keyof HTMLElementTagNameMap
>(
tagname: T,
newTagName = `pure-${tagname}` as `${string}-${string}`,
newTagName = `pure-${tagname}`,
constructor = custom.get(newTagName) as new () => WithLifecycle<
HTMLElementTagNameMap[T]
>
Expand Down

0 comments on commit 26243bb

Please sign in to comment.