During the last few years, the PrestaShop Project has been increasingly raising the code quality bar. To help maintainers ensure that quality keeps increasing, a number of automatic quality verification tools have been added to the CI pipeline:
- Stylelint verifies SCSS files, including the UIKit files.
- PHPStan finds errors and prevents introducing risky behavior in PHP files.
- PHP CS Fixer verifies code style in PHP files.
What are the benefits?
We have already seen the benefits of strictly typing in PHP: it has increased the codebase’s robustness by making type juggling bugs evident while coding and in CI. A type-safe environment reduces the chances of errors and enhances developers’ confidence in what they are building.
TypeScript also allows more expressive code, which will help new developers and contributors.
Why TypeScript and not another strict type library such as Flow?
There are many more reasons:
- TypeScript has better performance.
- It has a larger community (TypeScript is listed on state of JS).
- It’s open-source and backed by a big company (Microsoft).
- Most IDEs support it out of the box, providing autocomplete and inspections.
For the moment, only new components will be written using TypeScript. In time, we will progressively refactor important components such as grids and page scripts, to benefit from the enhanced stability and maintainability provided by TypeScript’s strong-typing features.