Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 624 Bytes

no-nullish-coalescing.md

File metadata and controls

28 lines (20 loc) · 624 Bytes

no-nullish-coalescing

This prevents the use of the Nullish Coalescing Operator:

let foo = null
const baz = foo ?? 1

These will not be allowed because they are not supported in the following browsers:

  • Edge < 80
  • Safari < 13.1
  • Firefox < 72
  • Chrome < 80

What is the Fix?

If the expression is short, you can consider using a ternary operator:

// these are all equivalent:
foo ?? bar
foo != null ? foo : bar
foo !== null && foo !== undefined ? foo : bar

This can be safely disabled if you intend to compile code with the @babel/plugin-syntax-nullish-coalescing-operator Babel plugin.