Subscribe on changes!

After vue@next3.2.x ,create by vite,The project con't read composition api

avatar
Oct 14th 2021

Version

3.2.20

Reproduction link

codesandbox.io

Steps to reproduce

create a project width vite and typescript, By the lastest version, import { InjectionKey, provide, inject } from 'vue', It's will report an error, TS2305: Module '"../../node_modules/vue/dist/vue"' has no exported member 'InjectionKey | provide | inject' tips: System: Mac OS

What is expected?

import { InjectionKey, provide, inject } from 'vue' can work in project

What is actually happening?

Module '"../../node_modules/vue/dist/vue"' has no exported member 'InjectionKey | provide | inject'

avatar
Oct 14th 2021

I can't reproduce this with a fresh Vite project, and you didn't provide an actual reproduction of the issue. Closing.

avatar
Oct 14th 2021

I can't reproduce this with a fresh Vite project, and you didn't provide an actual reproduction of the issue. Closing.

I'm sorry, you can fresh in https://codesandbox.io/s/typescript-vue3-error-dihwv, and my local project screenshots WX20211014-160938@2x

avatar
Oct 14th 2021

@LinusBorg InjectionKey is not exported. see docs https://v3.vuejs.org/api/composition-api.html#provide-inject and sfc

avatar
Oct 14th 2021

Yes it is.

image

https://github.com/vuejs/vue-next/blob/master/packages/runtime-core/src/apiInject.ts#L6

But import { InjectionKey } from 'vue' this line will show an error. Isn't this a bug?

avatar
Oct 14th 2021

@edison1105 because it should be import type { InjectionKey } from 'vue'?

avatar
Oct 15th 2021

The node version I use v12.18.1 & v14.15.2, I thought isn't a reson for node service. I find the node_modules @runtime-core, the following screenshots 142531634258207_ pic

avatar
Oct 15th 2021

I haven't reproduced your problem. Maybe the dependency has been destroyed. Try to delete node_modules and download the dependency again.