Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug on prefer destructuring when using with optional chaining

See original GitHub issue

Tell us about your environment

  • ESLint Version: v6.0.1
  • Node Version: v12.13.0
  • npm Version: 6.13.1

What parser (default, Babel-ESLint, etc.) are you using? @typescript-eslint/parser

Please show your full configuration:

module.exports = {
  extends: [
    // 'plugin:prettier/recommended',
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 10,
    sourceType: 'module',
    ecmaFeatures: {
      modules: true,
  rules: {
    quotes: [2, 'single', { allowTemplateLiterals: true, avoidEscape: true }],
    'jsx-quotes': [2, 'prefer-single'],
    'react/prop-types': 0,
    'no-mixed-operators': 0,
    'global-require': 0,
    'no-console': 2,
    'max-len': [1, 120, 2],
    'no-param-reassign': [2, { props: false }],
    'no-continue': 0,
    'no-underscore-dangle': 0,
    'generator-star-spacing': 0,
    'no-duplicate-imports': 0,
    'no-use-before-define': 0,
    'consistent-return': 0,
    'spaced-comment': 0,
    'arrow-parens': 0,
    'import/first': 1,
    'no-return-await': 0,
    'flowtype/define-flow-type': 1,
    'flowtype/use-flow-type': 1,
    'import/namespace': [2, { allowComputed: true }],
    'import/no-duplicates': 1,
    'import/order': [2, { 'newlines-between': 'always-and-inside-groups' }],
    'no-unused-vars': [
        ignoreRestSiblings: true,
    'no-await-in-loop': 0,
    'no-plusplus': 0,
    'import/prefer-default-export': 0,
    'no-confusing-arrow': 0,
    'no-restricted-syntax': 0,
    'no-bitwise': 0,
    'function-paren-newline': 0,
    'object-curly-newline': 0,
    'import/no-cycle': 1,
    'import/no-unresolved': [2, { ignore: ['@entria/graphql-mongoose-loader'] }],
    'import/no-self-import': 1,
    'import/extensions': [0, 'never', { ts: 'never' }],
    indent: 0,
    '@typescript-eslint/indent': 0,
    '@typescript-eslint/camelcase': 0,
    '@typescript-eslint/explicit-function-return-type': 0,
    'interface-over-type-literal': 0,
    '@typescript-eslint/consistent-type-definitions': 0,
    'lines-between-class-members': 0,
    '@typescript-eslint/explicit-member-accessibility': 0,
    '@typescript-eslint/prefer-interface': 0,
    '@typescript-eslint/interface-name-prefix': 0,
    '@typescript-eslint/no-non-null-assertion': 1,
    '@typescript-eslint/no-var-requires': 1,
    '@typescript-eslint/no-object-literal-type-assertion': 1,
    'import/no-extraneous-dependencies': 1,
    'prefer-const': [
        destructuring: 'all',
    'no-multi-assign': 1,
  plugins: ['flowtype', 'react', 'import', '@typescript-eslint'],
  globals: {
    require: true,
  env: {
    jest: true,
    node: true,
    es6: true,
    browser: true,
  settings: {
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      'eslint-import-resolver-typescript': true,
      'eslint-import-resolver-lerna': {
        packages: path.resolve(__dirname, 'packages'),

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const id = correlations?.id;

What did you expect to happen? it should keep like this:

const id = correlations?.id;

What actually happened? Please include the actual, raw output from ESLint. it changed to

const { id } = correlations;

causing a bug

Are you willing to submit a pull request to fix this bug?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

sibeliuscommented, Dec 4, 2019

updated @typescript-eslint/parser


mdjermanoviccommented, Dec 4, 2019

@sibelius which version of @typescript-eslint/parser are you using? It looks like this shouldn’t happen with 2.4.0 and above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prefer-destructuring - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Refactoring optional chaining into a large codebase - Lea Verou
Now that optional chaining is supported across the board, I decided to finally refactor Mavo to use it (yes, yes, we do provide...
Read more >
Overzealous Destructuring | Aleksandr Hovhannisyan
So destructuring the data is more dangerous than defensive coding (like using the optional chaining operator or good-old if statements).
Read more >
Should I just be using optional chaining expression ... - Reddit
Teach me how to destructure a 4 level nested object that is retrieved from an API request for rendering without using optional chaining...
Read more >
Optional Chaining - Function.prototype.apply was called on ...
This is definitely a bug - their experimental implementation of the optional chaining does not work with how they transpile calls with spread ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found