Skip to content

Typing renderable values #2359

Answered by kevinpschaaf
patorpey asked this question in Q&A
Discussion options

You must be logged in to vote

The reason that render() is typed as unknown is that lit will happily render any value. For example, it's perfectly valid to pass {toString() { return 'hi!'; } as a value to an expression, and lit will end up rendering the toString() value of it. So there is not a specific narrowing of types that Lit requires be passed to an expression.

If in your codebase you'd like to exclude certain types from the universe of values lit will render, the approach of defining type aliases to that subset seems perfectly reasonable.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aomarks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants