Enable exactOptionalPropertyTypes option in tsconfig (original) (raw)
What’s missing?
To enable exactOptionalPropertyTypes option in Octokit's tsconfig
Why?
Promoted by octokit/request-error.js#461, @wolfy1339 and I think it can be a good plan to enable this option.
The benefits are:
- Users of octokit with
exactOptionalPropertyTypes: trueoption won't have problems. Here you can see an example with the option enabled when using@octokit/request-error.js. - Required, but potentially
undefineddoes not have the same intent asoptional. This rule will enforce us to be explicit in our type declarations and how we expect octokit APIs should be used.1
Migration plan:
Enabling this feature, considering our multirepo architecture requires a progressive migration. The 2 alternatives I come up with are:
Upgrading each package tsconfig individually and finally upgrade @octokit/tsconfig
- A first idea I come up with is upgrading each package's
tsconfig.jsonindividually and adding the corresponding changes to the code, if any. Even this does not imply changes in code, I assume this should be aBREAKING CHANGEbecause our types become more strict to our users. Is this correct? - Once all the packages are upgraded, we can finally update
@octokit/tsconfigby adding this new option. - We wait for renovate to bump
@octokit/tsconfigin all our packages. - We re-visit all the packages (maybe with octoherd?) and remove the explicit rule in local's
tsconfig.json
Working with beta branches
- We release a
betaversion of@octokit/tsconfigwith the new property - We create
betabranches for each of Octokit's packages using this new version, and we apply the corresponding changes to the code if necessary. - Once everything is ready, we release a new
BREAKING CHANGEfor all the packages.
Warning
This change implies a BREAKING CHANGE to all packages. Is this correct?
A good blog explaining its potential benefits it can be found here: https://tkdodo.eu/blog/optional-vs-undefined