Skip to content

BenjMichel/gatsby-plugin-nullish-coalescing-operator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nullish coalescing operator support for Gatsby's Babel config

Description

It enables the nullish coalescing operator (a ?? b): see the TC39 proposal

How to install

Install the plugin and its dependencies :

npm i gatsby-plugin-nullish-coalescing-operator @babel/core @babel/plugin-proposal-nullish-coalescing-operator

or

yarn add gatsby-plugin-nullish-coalescing-operator @babel/core @babel/plugin-proposal-nullish-coalescing-operator

Add the plugin in gatsby-config.js:

module.exports = {
  plugins: [
    // other plugins
    'gatsby-plugin-nullish-coalescing-operator',
  ],
}

Examples of usage

const myString = '';
const headerText = myString ?? 'Default'; // result: '', whereas `myString || 'Default'` returns 'Default'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published