Vetur had destroyed my enjoyment of programming. The experience it provides in the IDE is too degraded. Most of the refactoring features of the TypeScript code don’t work, there are bugs with monorepos, and so on. With my TypeScript developer team, we spend maybe 95% of our time on TypeScript code, 4% on the SCSS code (yes, we have a designer who write most of the CSS for us), and we can generously count 1% of our time spent on the HTML code. This is why an HTML container is a bad format to write a web application.
Therefore, a year ago, we switched to the old method and abandoned SFC and its weird
.vue format. But since then, we have gradually created tools to import most of the benefits of the
In this tutorial, I will show a way to validate, at runtime, the conformity of a JSON configuration file, in any existing project. We will be able to use our own TypeScript definition of the configuration types, with the help of TypeOnly.
Let’s assume we have a Node.js project. In the main directory, the TypeScript source files are in a
dist/ directory. We also have a
config.json configuration file like this one:
TypeScript can help describe this data structure. …
I found a way to use Vuex stores in TypeScript without losing typing. It doesn’t require classes, so it is compatible with Vue 3 and the composition API.
At runtime, the library direct-vuex will create a wrapper around each getters, mutations and actions. We can use them from outside the store implementation.
So instead of writing:
… we write:
Or, instead of writing:
… we write:
Getters and mutations are accessible the same way:
The types of these wrappers are correctly inferred by TypeScript.
The store can be implemented in the same way as usual. …