fix: remove unnecessary type assertion from Context.Provider #145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request addresses the unnecessary type casting in the createSafeContext function. The Context.Provider is already correctly typed as T | typeof NullSymbol, so casting it to Provider is redundant and unnecessary. This change improves code readability and maintains type safety without unnecessary type assertions.
Changes
Removed the unnecessary type casting of Context.Provider to Provider in the createSafeContext function.
Simplified the type declaration to ensure the code is cleaner and easier t
Motivation and Context
This change was made to improve the maintainability of the code. By removing unnecessary type casting, we reduce complexity and make the codebase easier to understand. It's a best practice to avoid redundant type assertions, as they can lead to confusion and errors in the long run.
How Has This Been Tested?
The changes have been manually tested to ensure that the context provider and consumer still function correctly. No functional changes were expected from this update, so existing tests related to context usage were sufficient.
Types of changes
Checklist