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

Unnecessary type checking #1

Open
Jameskmonger opened this issue Mar 3, 2016 · 0 comments
Open

Unnecessary type checking #1

Jameskmonger opened this issue Mar 3, 2016 · 0 comments

Comments

@Jameskmonger
Copy link

Hi @gunar,

I'm not sure the type check (typeof isCrushed.name === 'string') is necessary here:

if (
  process.env.NODE_ENV !== 'production' &&
  typeof isCrushed.name === 'string' &&
  isCrushed.name !== 'isCrushed'
) {
  console.log('You are currently using minified code outside of NODE_ENV === \'production\'.')
}

By using the strict not-equals (!==) in the next check, we are guaranteeing that isCrushed.name has the same type as 'isCrushed', which is a string. Therefore the explicit type check is unnecessary.

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

No branches or pull requests

1 participant