Skip to content

Use unknown instead of any in type functions#3341

Merged
robertbrignull merged 3 commits intomainfrom
robertbrignull/unknown_type_checking
Feb 12, 2024
Merged

Use unknown instead of any in type functions#3341
robertbrignull merged 3 commits intomainfrom
robertbrignull/unknown_type_checking

Conversation

@robertbrignull
Copy link
Copy Markdown
Contributor

When checking if an object is a certain type, we should use unknown instead of any. The only difference this makes to the implementation is we need to add some extra obj !== null and typeof obj === "object" checks, but this makes it safer anyway since before if some of these were passed a null value they would throw an error when trying to access fields on it.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@robertbrignull robertbrignull requested a review from a team February 12, 2024 15:18
@robertbrignull robertbrignull requested a review from a team as a code owner February 12, 2024 15:18
Copy link
Copy Markdown
Member

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

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

Thanks!

@robertbrignull robertbrignull merged commit 6472ea8 into main Feb 12, 2024
@robertbrignull robertbrignull deleted the robertbrignull/unknown_type_checking branch February 12, 2024 15:57
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