Open samueljseay opened 4 months ago
I think I was naive when I wrote the suggested approach, because all the library packages will still need to generate type defs.
Updated suggestion of approach here: https://github.com/woocommerce/woocommerce/pull/47486/files#r1600825869
Right now we have a critical issue trying to update Gutenberg dependencies across the monorepo. A slight change in a dependency causes chains of TS errors, and makes it impossible to upgrade anything.
In the past we discussed turning off
tsc
and I'd like to reintroduce that idea here with some specific steps to take.We're not removing TS from the codebase, I'll just start there to ensure no one worries about that. We also have a goal of getting back to type-correctness so we should be able, some time in the future, to re-enable tsc compilation.The ideal situation to reduce friction is to use tsc to typecheck packages, emit errors as warnings but not block building the code base.
There are 3 kinds of situations with TS in the codebase right now:
1
is the top priority to fix, because most of the TS errors that we deal with when trying to update dependencies come out of these packages.To solve 1, I propose we convert the tsc compilation we do now to a 2 step process:
tsc
withnoEmit
, swallow error codes but emit all errors as warningsTo solve
2
, firstly I would like to see if1
is enough to allow us to update the majority of packages but if its not, we should adjust the TS / Webpack setup to just emit type errors but not block building the JS. We can use the approach suggested here: https://github.com/TypeStrong/ts-loader?tab=readme-ov-file#faster-builds which I've used in the past and it works fine.The next thing we need to solve after that is to track introduced TS errors and report on them in CI. We should consider whether we have some kind of threshold for what's considered a failure (ie introduced x or x% new errors) and block merging when that happens. I think though that the baseline of what errors exist should be established after we update WP packages to latest and also remove any dependency on
@types
packages for WP.