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

Prop has error type in template when it is a generic type which extends other type. #3654

Closed
FlareZh opened this issue Oct 12, 2023 · 4 comments
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first upstream

Comments

@FlareZh
Copy link

FlareZh commented Oct 12, 2023

This is the error:
image

Reproducible:

<script setup lang="ts" generic="T extends number">
const props = withDefaults(defineProps<{
	value?: T;
}>(), {
	value: 1 as any,
  // value: () => 1 as T
});
props.value.toFixed(2)
</script>

<template>
  {{ value.toFixed(2) }}
  {{ props.value.toFixed(2) }}
  {{ $props.value.toFixed(2) }}
</template>

link

@johnsoncodehk
Copy link
Member

Fixed by #3636, you can use props.value?.toFixed(2) after v1.8.17.

@johnsoncodehk johnsoncodehk added upstream good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels Oct 12, 2023
@FlareZh
Copy link
Author

FlareZh commented Oct 12, 2023

Fixed by #3636, you can use props.value?.toFixed(2) after v1.8.17.

Is there any plan to fix it when using value.toFixed(2)?

@johnsoncodehk
Copy link
Member

This is a type issue with defineComponent(), please report it to the core repo.

@FlareZh
Copy link
Author

FlareZh commented Oct 12, 2023

This is a type issue with defineComponent(), please report it to the core repo.

Ok, Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first upstream
Projects
None yet
Development

No branches or pull requests

2 participants