Skip to content
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

isInternalEntity: Assert the value is an object #117

Merged
merged 3 commits into from
Sep 10, 2021

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Sep 8, 2021

GitHub

Changes

  • Asserts that the given value is an object during the isInternalEntity check.

This prevents the isInternalEntity check to throw an exception when handling non-object types (still possible on runtime with the nested properties in model declarations).

TypeError: Cannot use 'in' operator to search for '__type' in "some value"

@kettanaito
Copy link
Member Author

Hey, @gidesan. Please, would you have a minute to review this change? I believe we can use it in your pull request, as well as in #98. I feel this is a general bug fix we should introduce regardless of the features. Thanks.

/**
* Returns true if the given value is a plain Object.
*/
export function isObject(value: any): value is Record<string, any> {
Copy link
Member Author

@kettanaito kettanaito Sep 8, 2021

Choose a reason for hiding this comment

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

Using unknown is more suitable here, but there have been some issues with adopting unknown for our TypeScript users in the past. I'd migrate from any to unknown as a separate, carefully released change.

@kettanaito kettanaito merged commit 3016d6d into master Sep 10, 2021
@kettanaito kettanaito deleted the fix/is-internal-entity-object branch September 10, 2021 11:13
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.

Handle Undefined Object in isInternalEntity
1 participant