Skip to content

Support optional chaining #835

@dalbani

Description

@dalbani

It would be great if njs could support optional chaining.

Looking at the codebase, I actually found this function pertaining to optional chaining:

njs_parser_optional_chain(njs_parser_t *parser, njs_lexer_token_t *token,

But, unless I'm doing something silly, it doesn't seem to work as I expected.
For example, a simple call like the following produces an error:

>> Object.xxx?.();
Thrown:
SyntaxError: Unexpected token "(" in shell:1

Whereas the same code in, say, Node.js, Firefox or Chrome will succeed:

undefined

So am I missing something obvious?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions