re: Type-Safe Web Components with JSDoc VIEW POST


That's truly awesome!

Did you explore the possibility to generate runtime "validators" for types? I think it can be useful to validate API responses or params from other components.

Also, I might miss something - can it be integrated with markup too?

return html`<my-element .unExistentProperty=${someVar} />`;

and the linting/VSCode complains about unExistentProperty


For runtime validators I'm not really sure if that can bring the functionality you want. Maybe take a look at Type Safety at Runtime where it argues that only you as a developer can truly make it happen.

For validation of API responses there is the OpenAPISpecification or Pact to get a strong contract for responses. I agree it would be nice to get types from the backend to the frontend but I do not know if there is any active development for such a spec. I know that certain full stack frameworks offer such functionality but to as far as I know these are always proprietary solutions with no intention to becoming a spec.

For markup type safety VS Code is currently working on using a web components "declaration file". Currently, it only supports attributes so please join the conversation and lets extend it with properties as well :)


Vaadin Connect is pretty cool, it generates TypeScript types for whatever you return from your java backend

code of conduct - report abuse