Skip to content

Support option chaining syntax highlighting #522

Closed

Description

@mjbvz

TS and JS Grammar Extension version: 0.0.22 / latest

From microsoft/vscode#34776 (comment)

Feature request
Support highlighting the proposed option chaining syntax for JS/TS

const a = {
  b: {
    c: {
      d: {
        e: 1,
        g: [1, 2, 3],
      },
    },
    f: null,
  },
};

const brokenSyntaxHighlighting = () => {
  const array = a?.b?.c?.d?.g;

  /**
   * No TypeEror, but syntax highlighting is broken
   */
  const test = a?.b?.f?.f;

  for (let i = 0; i < array.length; i++) {
    console.log(array[i]);
  }
};

brokenSyntaxHighlighting();

30707451-31af05c4-9f04-11e7-9b4f-12e6ff3ad2f8

TS support for this is tracked by: microsoft/TypeScript#16

Activity

  1. sheetalkamat commented on Oct 3, 2017

    @sheetalkamat
    Member

    This feature is still in stage 1. Will look at it once it gets into stage 3

  2. zalishchuk commented on Nov 28, 2017

    @zalishchuk

    Sheetal Nandi (@sheetalkamat) Is it really hard to implement syntax support for this feature? We have to use something like idx for these purposes which is not always convenient.

  3. oychao commented on Dec 22, 2017

    @oychao

    I need this very hardly.

  4. zalishchuk commented on Dec 24, 2017

    @zalishchuk
  5. fungilation commented on Jul 18, 2018

    @fungilation

    Time to revisit this, with React Native 56 integrating optional chaining support, now in babel 7.

    This is the best thing about coffeescript and so much more convenient than the verbose alternative. But broken syntax highlighting in VSCode is getting in the way of full adoption.

  6. mehulmpt commented on Jul 23, 2018

    @mehulmpt

    Well currently you can sort of get around this by disabling VSCode's internal javascript linter and using something like eslint, but obviously you lose some features of vscode linter like dimming of unused variables/imports, etc.

  7. fungilation commented on Jul 23, 2018

    @fungilation

    I see in my VSCode default config:

    "eslint.enable": true,
    

    Which tells me eslint is already the default VSCode linter? If not, how would you turn off the internal js linter?

    EDIT: I see this in settings is to turn off internal js validation, and I already have:

    "javascript.validate.enable": false,
    
  8. mjbvz commented on Jul 23, 2018

    @mjbvz
    Author

    This repository only handles syntax coloring. Semantic understanding of chaining is tracked by microsoft/TypeScript#16

  9. jabsatz commented on Sep 6, 2018

    @jabsatz

    Babel 7 has been released with the optional chaining operator as a plugin, is there any chance of revisiting this?

  10. daix6 commented on Aug 1, 2019

    @daix6

    This feature is still in stage 1. Will look at it once it gets into stage 3

    It's time!!

  11. bondparkerbond commented on Aug 7, 2019

    @bondparkerbond

    Optional Chaining is officially in Stage 3. Should this issue be reopened?

  12. spassvogel commented on Aug 12, 2019

    @spassvogel

    Please consider to implement this.

  13. orta commented on Aug 12, 2019

    @orta
    Contributor

    I agree, I think it's time this should get re-opened

  14. unbug commented on Sep 17, 2019

    @unbug
  15. nhardy commented on Oct 31, 2019

    @nhardy

    Orta Therox (@orta) Sheetal Nandi (@sheetalkamat) Should this be reopened? It looks like #768 only added nullish coalescing support, not support for optional chaining which will land in TS3.7 on November 5th.

  16. sheetalkamat commented on Nov 4, 2019

    @sheetalkamat
    Member

    Nathan Hardy (@nhardy) optional chaining is supported. If you have a sample that doesnt work please open another issue with it to track it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions