Skip to content

Support for TypeScript 3.7 optional chaining and nullish coalescence #1661

Closed
@ghost

Description

What problem does this feature solve?

Right now it's impossible to use optional chaining or nullish coalescence in the template part of a Vue component, when using Vue with TypeScript. This was a new future introduced in the past few months on TypeScript 3.7.

Any template containing optional chaining within {{ }} will throw the following error:

Failed to compile.

  Errors compiling template:

  invalid expression: Unexpected token '.' in

    _s(myObject?.x.y)

  Raw expression: {{ myObject?.x.y}}

A similar error happens when trying to use nullish coalescence such as:

{{ myOptionalProperty ?? 'My default message' }}

It would be nice to have support for this so we don't have to resort to the old way of checking chains or having to always move the code to the TypeScript block.

What does the proposed API look like?

I apologise but I'm not knowledgeable enough to know how to change the API in this regard.
I can only assume that under the hood the loader should understand the behaviour of .? and ?? the same way that TypeScript does.

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