Agontuk / vue-cropperjs

A Vue wrapper component for cropperjs https://github.com/fengyuanchen/cropperjs
MIT License
932 stars 225 forks source link

Property does not exist on Type (Vue 3 + setup syntax + TS) #130

Open pixelmusik opened 9 months ago

pixelmusik commented 9 months ago

I am getting compiler errors when using the cropper along with Vue 3 setup syntax and TypeScript.

AppComponent.vue

<template>
    <vue-cropper ref="cropper" src="demo.jpg" />
</template>

<script setup lang="ts">
    import { ref, onMounted } from "vue";
    import VueCropper from "vue-cropperjs";

    const cropper = ref<InstanceType<typeof VueCropper>>();

    onMounted(() => {
        // This throws a compiler error (Property "reset" does not exist on type...)
        cropper.value?.reset();
    });
</script>

For each method called this way I am getting a compiler error.

TS2339: Property 'reset' does not exist on type 'CombinedVueInstance<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => V
ue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 7 more ..., OptionTypesType<...>>'.

I have the following node packages installed.