Typescript-eslint: Optional chaining syntax is still not supported

Created on 5 Dec 2019  路  1Comment  路  Source: typescript-eslint/typescript-eslint

What code were you trying to parse?

const a: { x: number; y: number; z?: number} = { x: 1, y: 2 };
const b = a?.z ?? 3;

console.log(b);

What did you expect to happen?
Get the right results, not the wrong ones

What actually happened?
Expression expected.
Expected ':'.

Versions

| package | version |
| --------------------------- | ------- |
| @typescript-eslint/parser| "^2.10.0"
| TypeScript |"^3.7.3",
| ESLint |"^6.7.2"
| node |v13.0.1
| npm | 6.13.0

config

  • .eslintrc.js
module.exports = {
  root: true,
  extends: ["alloy", "alloy/typescript"],
  parser: "@typescript-eslint/parser",
  env: {
    // Your environments (which contains several predefined global variables)
    //
    browser: true,
    node: true,
    es2017: true,
    mocha: true
    // node: true,
    // mocha: true,
    // jest: true,
    // jquery: true
  },
  globals: {
    // Your global variables (setting to false means it's not allowed to be reassigned)
    //
    // myGlobal: false
  },
  rules: {
    'no-undef': 0
  }
};

  • package.json
{
  "name": "page",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@babel/core": "^7.7.4",
    "@babel/plugin-proposal-class-properties": "^7.7.4",
    "@babel/plugin-proposal-optional-chaining": "^7.7.4",
    "@babel/preset-env": "^7.7.4",
    "@typescript-eslint/eslint-plugin": "^2.10.0",
    "@typescript-eslint/parser": "^2.10.0",
    "autoprefixer": "^9.7.3",
    "babel-eslint": "^10.0.3",
    "babel-loader": "^8.0.6",
    "clean-webpack-plugin": "^3.0.0",
    "core-js": "^3.4.7",
    "css-loader": "^3.2.0",
    "ejs-loader": "^0.3.5",
    "eslint": "^6.7.2",
    "eslint-config-alloy": "^3.4.0",
    "eslint-loader": "^3.0.2",
    "extract-loader": "^3.1.0",
    "file-loader": "^5.0.2",
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.2.0",
    "mini-css-extract-plugin": "^0.8.0",
    "node-sass": "^4.13.0",
    "postcss-loader": "^3.0.0",
    "sass-loader": "^8.0.0",
    "style-loader": "^1.0.1",
    "ts-loader": "^6.2.1",
    "typescript": "^3.7.3",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "url-loader": "^3.0.0",
    "webpack": "^4.41.2",
    "webpack-cli": "^3.3.10",
    "webpack-dev-server": "^3.9.0",
    "webpack-merge": "^4.2.2"
  },
  "scripts": {
    "serve": "cross-env NODE_ENV=development webpack-dev-server --config build/webpack.config.js",
    "build": "cross-env NODE_ENV=production webpack --config build/webpack.config.js"
  },
  "dependencies": {
    "cross-env": "^6.0.3"
  }
}

parser wontfix

>All comments

It's supported fine, and has been supported since before its release.
There are passing tests, and there are millions of other users that this is working fine for.

If I were to hazard a guess, the configs you're extending are using the wrong versions of packages like prettier, our packages, or typescript.

Please ensure that all of your packages are up to date.

Was this page helpful?
0 / 5 - 0 ratings