You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 👍
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: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.The text was updated successfully, but these errors were encountered: