@bumped-inc/gatsby-plugin-optional-chaining

1.0.0 • Public • Published

Optional chaining support for Gatsby's Babel config

Description

It enables the optional chaining operator (a ?. b): see the TC39 proposal

How to install

Install the plugin and its dependencies :

npm i @bumped-inc/gatsby-plugin-optional-chaining @babel/core @babel/plugin-proposal-optional-chaining

or

yarn add @bumped-inc/gatsby-plugin-optional-chaining @babel/core @babel/plugin-proposal-optional-chaining

Add the plugin in gatsby-config.js:

module.exports = {
  plugins: [
    // other plugins
    '@bumped-inc/gatsby-plugin-optional-chaining',
  ],
}

Examples of usage

const maybeObj = null;
const result = maybeObj?.value; // result: undefined

const actualObj = { value: 5 };
const betterResult = actualObj?.value // betterResult: 5

Package Sidebar

Install

npm i @bumped-inc/gatsby-plugin-optional-chaining

Weekly Downloads

205

Version

1.0.0

License

MIT

Unpacked Size

1.92 kB

Total Files

5

Last publish

Collaborators

  • kingles
  • bumped-robot
  • reichjustin
  • eoconnor