payload icon indicating copy to clipboard operation
payload copied to clipboard

chore: migrate to TypeScript strict in Payload package (enable strictNullChecks) - #3

Open GermanJablo opened this issue 7 months ago • 0 comments

Important: An intentional effort is being made during migration to not modify runtime behavior. This implies that there will be several assertions, non-null assertions, and @ts-expect-error. This philosophy applies only to migrating old code to TypeScript strict, not to writing new code. For a more detailed justification for this reasoning, https://github.com/payloadcms/payload/pull/11840#discussion_r2021975897.

In this PR, instead of following the approach of migrating a subset of files, I'm migrating all files by disabling a specific rule. In this case, strictNullChecks.

strictNullChecks is a good rule to start the migration with because it's easy to silence with non-null assertions or optional chainings. Additionally, almost all ts strict errors are due to this rule.

This PR improves 200+ files, leaving only 68 remaining to migrate to strict mode in the payload package.

GermanJablo avatar May 28 '25 11:05 GermanJablo