TypeScript Action Plan
We've started adding the 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.
TypeScript is for internal implementation only. Does NOT affect ES users, but should improve TS integration for TS users.
Therefore we're refactoring just:
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 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 existing UI layer (components, pages) to use TypeScript. We should focus at 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 1-2 interfaces per entity (e.g. Product shouldn't be represented by more than 2 interfaces)