Skip to content

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

Merged
GermanJablo merged 44 commits into
mainfrom
strictNullChecks
Jun 3, 2025
Merged

GermanJablo merged 44 commits into
mainfrom
strictNullChecks

Conversation

@GermanJablo

@GermanJablo GermanJablo commented May 28, 2025 •

Copy link
Copy Markdown
Contributor

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.

denolfe
denolfe previously approved these changes May 30, 2025

@denolfe denolfe left a comment

Copy link
Copy Markdown
Member

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
Comment thread packages/payload/src/config/sanitize.ts Resolved
Comment thread packages/payload/src/config/sanitize.ts Resolved
DanRibbens
DanRibbens previously approved these changes Jun 2, 2025

@DanRibbens DanRibbens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!
I had a few minor questions.

@GermanJablo
GermanJablo dismissed stale reviews from DanRibbens and denolfe via ab83799 June 3, 2025 14:06
@GermanJablo
GermanJablo requested a review from DanRibbens June 3, 2025 14:07
@github-actions

github-actions Bot commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.41.0

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.

3 participants