Open 07akioni opened 3 years ago
I can't reproduce this problem. My project is created by @vue/cli@5.0.0-alpha.0
. Could you provide the information in the issue bug template? It's a compile error or just a vetur error message ?
(vue info
is updated)
Type check simply not works in main.ts
.
I use ([Vue 3] typescript, eslint, unit-jest, e2e-cypress)
preset and only main.ts
is modified as shown.
msg
should be a string.
In shims-vue.ts
:
/* eslint-disable */
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
I think it makes in .ts
files, all the imported .vue
vars are not treated as their real type but empty defineComponent()
?
you are right. As far as I know, you should define declare module '@/components/HelloWorld.vue'
by yourself. Or use HelloWorld.tsx
. I'm not sure if vetur
can support the feature you want
you are right. As far as I know, you should define
declare module '@/components/HelloWorld.vue'
by yourself. Or useHelloWorld.tsx
. I'm not sure ifvetur
can support the feature you want
Vetur seems to make type checks in .vue
's script part work. However in .ts
it doesn't work.
😭
I think you need plugin like vue-ts-plugin, Unfortunately, it seems this plugin doesn't support vue3 now.
Related issue https://github.com/vuejs/vetur/issues/1322, https://github.com/vuejs/vetur/issues/673, https://github.com/vuejs/vetur/issues/2016
I think you need plugin like vue-ts-plugin, Unfortunately, it seems this plugin doesn't support vue3 now.
Related issue vuejs/vetur#1322, vuejs/vetur#673, vuejs/vetur#2016
Thanks.
It may take a long time to make vue3 development tool chains mature. 😄
https://github.com/znck/vue-developer-experience
It can make type check work.
![Uploading image.png…]()
using @vuedx/typescript-plugin-vue
,
I should run the Select TypeScript version command in VS Code to use the workspace version of TypeScript. It's not out of the box for vscode users if integrating this plugin in CLI. But this plugin can be mentioned in the documentation maybe.
this plugin doesn't support .vue
which doesn't contain script tag, we can use this plugin with shims-vue.d.ts
together to solve this problem.
maybe it would be better to let vetur
integrate it. https://github.com/vuejs/vetur/pull/2145. I'm not very sure now.
using
@vuedx/typescript-plugin-vue
,
- I should run the Select TypeScript version command in VS Code to use the workspace version of TypeScript. It's not out of the box for vscode users if integrating this plugin in CLI. But this plugin can be mentioned in the documentation maybe.
- this plugin doesn't support
.vue
which doesn't contain script tag, we can use this plugin withshims-vue.d.ts
together to solve this problem.maybe it would be better to let
vetur
integrate it. vuejs/vetur#2145. I'm not very sure now.
There is vuedx extension in vscode store, which can be used with vetur together (not recommended, I find it seems to slow down my vscode, not quite sure).
Before Vue3 DX reach a usable level, I think we still need to wait for some tool chains to reach stable state.
For type checking like tsc --noEmit
, we need @vuedx/typecheck
.
For type checking in IDE like tsx
, we need vetur
to support both .ts|js|vue
in vscode. (After that shims-vue.d.ts
is not required)
For packing a .ts + .vue
library in its file original structure, currently there is no integrated solution. (For .ts + tsx
it is quite easy. just run tsc
)
For people who want to use typescript tsc
to build their library, I build v2s
(vue to script) to help convert .vue
file to .ts
file and refactor all the related imports/exports.
It does the conversion in place.
Firstly copy src
to copied-src
copied-src/Button.vue (lang=ts)
copied-src/index.ts (import Button from './Button.vue')
Run npx v2s -dr copied-src/**/*
(-dr
means delete source & refactor imports/exports)
copied-src/Button__render.ts
copied-src/Button__script.ts
copied-src/Button.ts
copied-src/index.ts (import Button from './Button.ts')
Then you can use tsc
to compile your library.
What problem does this feature solve?
I find in vscode (with vetur), props check works in
.vue
file when editing.However it doesn't work in
.ts
file.Is there any way to make type checks work in .ts files?
What does the proposed API look like?
Nil
Vue Info