Compile-time prop types

Pass the shape of your defaults as a type argument — extends WebComponent<typeof props> — and this.props.* is inferred from them instead of being any.

The buttons above are ordinary reactive props; the point of this example is what the compiler now sees. In index.ts below, this.props.variant is string, this.props.disabled is boolean, and each line in CompileErrors is a real type error kept honest by @ts-expect-error.


Without the type argument

Omitting it keeps the previous behavior: every read is any, so a typo like this.props.varient compiles fine.

Runtime is unchanged either way. Types are erased before the browser sees this file — static strictProps is still what guards values arriving from attributes at runtime.