From 26243bbb1b73fb1643870f9c10da226e9e4227d8 Mon Sep 17 00:00:00 2001 From: Shiba <44804845+DeepDoge@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:46:11 +0000 Subject: [PATCH] WithLifecycle parameters was generating non-optional types. fixed that by explicitly typing WithLifecycle --- lib/tags.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tags.ts b/lib/tags.ts index 2a3b132..5879959 100644 --- a/lib/tags.ts +++ b/lib/tags.ts @@ -280,9 +280,14 @@ export type WithLifecycle = T & { effect(callback: Lifecycle.OnConnected): Lifecycle.OffConnected } -export let WithLifecycle = ( +export let WithLifecycle: ( + tagName: T, + newTagName?: `${string}-${string}` +) => { new (): WithLifecycle } = < + T extends keyof HTMLElementTagNameMap +>( tagname: T, - newTagName = `pure-${tagname}` as `${string}-${string}`, + newTagName = `pure-${tagname}`, constructor = custom.get(newTagName) as new () => WithLifecycle< HTMLElementTagNameMap[T] >