Skip to content

Conversation

@royalrex
Copy link

Summary

Changing of MigrationFunction type. The context parameter should not be declared as optional.

Description

This PR removes the optional setting on the context parameter. This will hint typescript that the parameter will always be there. My research of your codebase indicates that the context will always be provided.

I assume that your intent with marking the context as optional, is to not force other developers to have context parameter present in their migration function signature. But that is not what is happening. Typescript is okay with "missing" parameters, but marking it optional as is, will force developers to null check the context object before using. This seems to be not needed.

Motivation and Context

Improves typescript type checking.

Todos

  • Implemented feature
  • Feature with pending implementation

Screenshots (if appropriate):

Typescript before change with context parameter
image

Typescript after change with context parameter
image

Typescript after change with no context parameter
image

@royalrex royalrex requested a review from a team as a code owner November 28, 2023 11:03
Copy link
Contributor

@mgoudy91 mgoudy91 left a comment

Choose a reason for hiding this comment

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

I took a look and came to the same conclusion and believe this is fairly safe (and correct).

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants