Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

GermanJablo
Copy link
Contributor

@GermanJablo GermanJablo commented May 28, 2025

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, #11840 (comment).

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.

Copy link
Member

@denolfe denolfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any objections. Would like to get a few more eyes/approvals here for visibility, though.

@denolfe denolfe requested a review from DanRibbens May 30, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants