Closed gu-stav closed 1 month ago
Maybe another interesting bit to this: I am observing other obscure errors whenever conditional types are in play. For example:
<script setup lang="ts">
type EditCatalogTranslationFormCommonProps = {}
type EditCatalogTranslationFormConditionalProps =
| {
/* Catalog translation initial data */
translationInitial?: GetCatalogTranslation.Response['data']
}
| {
/* Catalog translation source */
translationSource?: GetCatalogTranslation.Response['data']
}
type EditCatalogTranslationFormProps = EditCatalogTranslationFormCommonProps &
EditCatalogTranslationFormConditionalProps
const props = defineProps<EditCatalogTranslationFormProps>()
const translationInitialSectionsFlat = computed(() =>
flattenSections('translationInitial' in props ? (props.translationInitial?.sections ?? []) : [])
)
</script>
<template>
<span>
{{
(
translationInitialSectionsFlat.find(
(section) => section.type === row.type && section.id === props.row.id
) as RowMeasure | undefined
)?.description?.text ?? t('Missing translation')
}}
</span>
</template>
While translationInitialSectionsFlat
is properly typed in script setup
it suddenly looses its type in the template:
As soon as I remove & EditCatalogTranslationFormConditionalProps
the type is inferred properly.
Hi @gu-stav you seem to be using vue @ version 3.2 - is that correct? Please try using just vue@latest (5.4.x). There seems to be something wrong with your canary override
Hi @davidmatter. I am using the latest canary version of vue@3.5.
This canary release is outdated. Please use 3.4.x or the 3.5 alpha version.
@davidmatter How is this canary release outdated? This is what the offical documentation about using the canary version is recommending: https://vuejs.org/about/releases using npx install-vue@canary-minor
Also: the canary release is from Junly the 15th and since then there hasn't been a new canary release.
Not sure about that, you might want to ask in @vue/core - there might be an issue with canary releases
I've created a PR @ vue/core https://github.com/vuejs/core/pull/11516 This will fix the broken canary release workflow.
Thanks a lot @davidmatter 🙏🏼
Vue - Official extension or vue-tsc version
2.0.29
VSCode version
Version: 1.91.1 Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:07:46.768Z (3 wks ago)
Vue version
@vue/canary@3.20240715.0-minor.0
TypeScript version
5.5.3
System Info
Steps to reproduce
vue-tsc --build --force
What is expected?
Running
vue-tsc --build --force
should not error on this.What is actually happening?
The following type error is thrown
Vscode does not display the error inline, which is the reason I suspected
vue-tsc
instead ofvue
.Link to minimal reproduction
No response
Any additional comments?
I having the same problem in different shapes throughout the codebase:
Another interesting instance of this seems to be the following:
In Vscode the type is inferred properly:
but
vue-tsc
throws an errorI have installed the
vue
canary minor version as documented here: https://vuejs.org/about/releases. Mypackage.json
now looks like:I hope that helps. If you need any more help reproducing the issue please let me know 🙏🏼