Vue Cli Project Enable Optional Chaining

Nov 29, 2019

NOTE: You might want to upgrade to latest plugins

Optional Chaining: item?.name.

via Babel

Install

npm install --save-dev @babel/plugin-proposal-optional-chaining

Edit babel.config.ts to add @babel/plugin-proposal-optional-chaining in plugins

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ],
  plugins: [
    '@babel/plugin-proposal-optional-chaining'
  ]
}

via TypeScript

npm install typescript@latest

NOTE: Need at least version 3.7.2

Edit tsconfig.json: change target to es2020.

{  "compilerOptions": {    // "target": "esnext",    "target": "es2020",    ...  }}

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.