Skip to content

What's the strategy for asserting DOM elements as custom elements in TypeScript? #899

Answered by xdev1
andyjessop asked this question in Help
Discussion options

You must be logged in to vote

What about the following?

 (document.getElementById(alert.id) as SlAlert)?.toast();

or

 document.querySelector<SlAlert>(`#${alert.id}`)?.toast();

How shall getElementById (or ShoelaceComponent) know about the concrete element type without anyone declaring it explicitly?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andyjessop
Comment options

Answer selected by andyjessop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants