'Unable to import defineEmits interface from another file [Vue3 with script setup + TS]

This works good for me:

<script setup lang="ts">
import { defineEmits } from 'vue';
import { ProjectInfo } from 'src/ts/types/main';

interface xyzSelectProjectEmits {
    (e: 'projectSelected', selectedProject: ProjectInfo | undefined): void;
}

const emits = defineEmits<xyzSelectProjectEmits>();

This, doesn’t:

<script setup lang="ts">
import { defineEmits } from 'vue';
import { xyzSelectProjectEmits } from 'some/path'

let x:xyzSelectProjectEmits;
const emits = defineEmits<xyzSelectProjectEmits>();

ESLint complains about: “Unsafe assignment of an any value” for const emits... but everything goes well with let x...

I’m doing something stupid that I’m not seeing right now? Or it’s an ESLint problem?



Solution 1:[1]

This seems to currently be a limitation with Vue and typescript. There is an issue open about it on Github https://github.com/vuejs/core/issues/4294

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Derrik Milligan