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

Vite doesn't seem to resolve TypeScript aliases properly #5476

Closed
7 tasks done
AdrianLeeElder opened this issue Oct 29, 2021 · 2 comments
Closed
7 tasks done

Vite doesn't seem to resolve TypeScript aliases properly #5476

AdrianLeeElder opened this issue Oct 29, 2021 · 2 comments

Comments

@AdrianLeeElder
Copy link

Describe the bug

When trying to use a TypeScript type alias from another module, vite throws the following error:

[plugin:vite:vue] [@vue/compiler-sfc] type argument passed to defineEmits() must be a function type, a literal type with call signatures, or a reference to the above types.

/home/projects/vitejs-vite-jp64f7/src/App.vue
4  |  import HelloWorld from './components/HelloWorld.vue'
5  |  import {GlobalEmits} from './types/index'
6  |  const emit = defineEmits<GlobalEmits>()
   |                           ^^^^^^^^^^^
7  |  </script>
8  |
/home/projects/vitejs-vite-jp64f7/src/App.vue

Reproduction

https://stackblitz.com/edit/vitejs-vite-jp64f7?file=src/App.vue

System Info

System:
    OS: Linux undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: Unknown - /bin/jsh
  Binaries:
    Node: 14.16.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm
  npmPackages:
    @vitejs/plugin-vue: ^1.9.4 => 1.9.4 
    vite: ^2.6.13 => 2.6.13

Used Package Manager

npm

Logs

No response

Validations

@Niputi
Copy link
Contributor

Niputi commented Oct 29, 2021

could you try writing this?

import type {GlobalEmits} from './types/index'

@wheatjs
Copy link

wheatjs commented Oct 31, 2021

This is an issue with Vue, not Vite vuejs/core#4294

I've written a Vite plugin to support this, but it is still very experimental https://github.com/wheatjs/vite-plugin-vue-type-imports

@wheatjs wheatjs closed this as completed Oct 31, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants