Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for TypeScript 3.7 optional chaining and nullish coalescence #1661

Closed
ghost opened this issue Apr 9, 2020 · 2 comments
Closed

Support for TypeScript 3.7 optional chaining and nullish coalescence #1661

ghost opened this issue Apr 9, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 9, 2020

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.

@haoqunjiang
Copy link
Member

See vuejs/vue#11088

@ghost
Copy link
Author

ghost commented Apr 9, 2020

See vuejs/vue#11088

Oh thank you! Because it throws an error from the loader I tried searching here in this repo for someone who reported a similar issue and couldn't find anything. I'll close the issue and my team will just wait until we can upgrade to Vue 3 👍

@ghost ghost closed this as completed Apr 9, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant