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

[Bug report] Unexpected change with isPlainObject #1610

Closed
Mister-Hope opened this issue Sep 30, 2024 · 1 comment
Closed

[Bug report] Unexpected change with isPlainObject #1610

Mister-Hope opened this issue Sep 30, 2024 · 1 comment
Assignees

Comments

@Mister-Hope
Copy link
Member

Mister-Hope commented Sep 30, 2024

Description

image

The above image should show the main difference of the previous one and the new one.

The new one is losing the ability to type cast to a specific interface

@Mister-Hope
Copy link
Member Author

The isPlainObject also has some fail positive comparing with typeof x === 'object':

interface Test {
 key: string
}

let test: Test | false;

if (typeof test === 'object') {
  // test is now Test
}

if (isPlainObject(test)) {
  // oops, test is now Record<string, unknown>
}

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

No branches or pull requests

2 participants