-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Remove as
assertions, or fix to mitigate the risk of silent failure
#158
Commits on Oct 13, 2023
-
Replace
as T[]
assertions with?? []
- `as` assertions intended to exclude an empty/nullable type can be replaced by a nullish coalescing operator converting nullable values into an acceptable empty value that doesn't pollute the variable's type signature. - TODO: document and expound in MetaMask/contributor-docs#47
Configuration menu - View commit details
-
Copy full SHA for 53cf673 - Browse repository at this point
Copy the full SHA 53cf673View commit details -
Replace
as
assertions with redundant type guardsSometimes TypeScript's type narrowing and inference doesn't fully work quite like it should. Even in these cases, using `as` assertions should be avoided. It may seem like we know for certain what the type should be and there's no risk of it breaking, but there's always the possibility that some combination of changes elsewhere might affect the typing, in which case `as` will suppress the alerts TypeScript would otherwise provide us with. This may lead to code breaking silently. In this case, adding type guards and null checks -- even if they're redundant -- is preferable to the above scenario. - TODO: document and expound in MetaMask/contributor-docs#47
Configuration menu - View commit details
-
Copy full SHA for f950f3e - Browse repository at this point
Copy the full SHA f950f3eView commit details -
Make
as
assertion rely on inference instead of hard-coded type castingIf anything changes in the typing of `ChangeCategory` or `unreleasedChanges` that make them inconsistent, this code will fail silently. Relying on type inference instead of explicit type casting will make these line a little less brittle. - TODO: document and expound in MetaMask/contributor-docs#47
Configuration menu - View commit details
-
Copy full SHA for 8da9f21 - Browse repository at this point
Copy the full SHA 8da9f21View commit details
Commits on Oct 16, 2023
-
Fix type narrowing for
currentVersion
by consolidating conditional ……branches - more consistent logic for `isReleaseCandidate` null check - wasted processing overhead due to errors throwing later than strictly necessary
Configuration menu - View commit details
-
Copy full SHA for 033cd4e - Browse repository at this point
Copy the full SHA 033cd4eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 44cc00d - Browse repository at this point
Copy the full SHA 44cc00dView commit details -
Replace
Object.keys
withgetKnownPropertyNames
method- removes need for type casting while iterating over object keys
Configuration menu - View commit details
-
Copy full SHA for d788964 - Browse repository at this point
Copy the full SHA d788964View commit details
Commits on Oct 17, 2023
-
Configuration menu - View commit details
-
Copy full SHA for a26b0bb - Browse repository at this point
Copy the full SHA a26b0bbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7b7eef8 - Browse repository at this point
Copy the full SHA 7b7eef8View commit details