Skip to content

chore: migrate to TypeScript strict in Payload package - Part 2/N #12574

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 4 commits into
base: main
Choose a base branch
from

Conversation

GermanJablo
Copy link
Contributor

Important: An intentional effort is being made during migration to not modify runtime behavior except in very rare exceptions. 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, read this comment.

@@ -27,7 +24,7 @@ export type BaseVersionField = {

export type VersionField = {
field?: BaseVersionField
fieldByLocale?: Record<TypedLocale, BaseVersionField>
fieldByLocale?: Record<string, BaseVersionField>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TypedLocale can be either string or null

Comment on lines +7 to +9
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
const secret = this.secret
const cipher = crypto.createCipheriv(algorithm, secret, iv)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I think it might be useful to someone in the future, I'm sharing the reasoning here as a safety tip: extracting the conflicting variable to a new line is intentional. I tend to do this because if another error appears on the line below, @ts-expect-error would silence them all.

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.

1 participant