TypeScript Action Plan
We've started adding TypeScript support to Vue Storefront, mostly because of the following reasons:
- Developer convenience (IntelliSense support in the IDEs)
- Types safety and code-testability
- Making Vue Storefront code base easier to understand for newcomers.
Therefore we're only refactoring:
where it makes sense. The key TypeScript feature we feel is usable are data types.
We're in the middle of refactoring
core/api modules. All the modules should be created using TypeScript
The Action Plan:
- Introduce types - move _.js modules to _.ts modules incrementally without breaking changes.
- Use types when it's appropriate in your newly written modules and new features.
- One Vuex module or just a few components refactored within one release (once a month) is fine.
core/apimodules should be created using TypeScript.
- All new modules and Vuex stores should be created using TypeScript.
- For now, please don't refactor the existing UI layer (components, pages) to use TypeScript. We should focus on Vuex, core libraries, and APIs at first to not introduce chaos into theme development.
- We should put the types/interfaces inside
core/store/typesfor all Entity/Data related models or in
core/typesfor some shared ones—for example:
Product.tsshould be placed in
- We should use a minimal possible set of interfaces. Try to introduce one or two interfaces per entity (e.g. Product shouldn't be represented by more than two interfaces).