3 ms·
Static analysis works on strings: source code. Similarly, it can, and does work on the strings in a tagged template literal. Lit's templates are HTML with bind
by spankalee 2y ago
Static analysis works on strings: source code. Similarly, it can, and does work on the strings in a tagged template literal.
Lit's templates are HTML with bindings. They're very analyzable, including checking for valid structure, associating tags with definitions, type-checking bindings. The tools that do this parse template strings, build an AST, and run analysis passes just like other source analysis tools.
Developers get standard intellisense features like jump-to-definition, hover-over docs, errors on invalid properties and events, etc.
But also... templating is an implementation concern.
To build a web component you don't have to use a tagged-template-based system. There are template systems that use JSX. You can use Preact, or React themselves. And your component users don't ever have to know what template system you chose to implement your component.