Closed ghost closed 3 years ago
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 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
0.3.0
This is upstream problem, see https://github.com/johnsoncodehk/volar/issues/93.
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.
Error:
Error:
vue-tsc version is
0.3.0