This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Errors when attempting to use a prop validator #76
Closed

Description
Maybe I'm just doing it wrong, but when I add a prop validator for a Vue 3 project, I get all kinds of nonsensical TS errors inside my setup method. When I remove the validator the errors go away.
<template>
<template>
<script lang="ts">
import { defineComponent, computed } from 'vue';
export default defineComponent({
name: 'Example',
props: {
str: {
type: String,
required: true,
validator(value: unknown) {
return value.length > 2;
}
}
},
setup(props) {
const greeting = computed(() => "Here's the string: " + props.str);
return { greeting };
}
});
</script>
Error:
error TS2571: Object is of type 'unknown'.
return value.length > 2;
~~~~~
Error:
error TS2339: Property 'str' does not exist on type 'Readonly<LooseRequired<Readonly<readonly unknown[] & { [x: number]: string; } & { toString?: string | undefined; toLocaleStr
ing?: string | undefined; concat?: string[] | undefined; indexOf?: ((searchElement: string, fromIndex?: number | undefined) => number) | undefined; ... 18 more ...; flat?: unknown[] | undefined...'.
const greeting = computed(() => "Here's the string: " + props.str);
~~~
vue-tsc version is 0.3.0