Closed bigmistqke closed 1 month ago
@bigmistqke hello! That's interesting. What's the definition of BundledLanguage
?
Tito told me about your repl. Pretty sweet, like how it pulls in the types! Can you paste the example in the repl and link here to try out?
Oh wait does the repl have link sharing yet? If no, just paste types here, I can copy/paste.
hey joe :wave:
i have been playing around with
lume/elements
to make custom-element export for solid-shiki-textarea.Issue
I noticed that the attributes of the custom-element were always
string
, while I defined the type with a more narrow type:I extended the namespace with
ElementAttributes<ShikiTextareaElement, ...>
:Own exploration
I had a look inside
ElementAttributes
:And found that the culprit was
Type[Property] extends string
.Type[Property]
is in my setup typed asBundledLanguage | undefined
which causes it to not fullfill the conditional.Type[Property] | string
causes the type to be widened tostring
.The fact that
Type[Property]
is typed asBundledLanguage | undefined
and notBundledLanguage
is due to my tsconfig setting:"noUncheckedIndexedAccess": true
.Patch
I was able to patch it to create the behavior that I wanted in the following way:
where I wrapped
Type[Property]>
in aNonNullable
to excludeundefined
from its type.I am not sure if this is the correct solution, that's why I preferred to write it up as an issue instead of a PR.