Skip to content

Commit 1a54e58

Browse files
chore(create-vite): align vue template with create-vue (#11128)
Co-authored-by: Haoqun Jiang <[email protected]>
1 parent 97f8b4d commit 1a54e58

File tree

7 files changed

+10
-18
lines changed

7 files changed

+10
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["Vue.volar"]
2+
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
33
}

packages/create-vite/template-vue-ts/README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ This template should help get you started developing with Vue 3 and TypeScript i
44

55
## Recommended IDE Setup
66

7-
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
7+
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
88

99
## Type Support For `.vue` Imports in TS
1010

11-
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
11+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
1212

13-
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
14-
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
13+
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1514

16-
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
15+
1. Disable the built-in TypeScript Extension
16+
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
17+
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
18+
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

packages/create-vite/template-vue-ts/src/App.vue

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script setup lang="ts">
2-
// This starter template is using Vue 3 <script setup> SFCs
3-
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
42
import HelloWorld from './components/HelloWorld.vue'
53
</script>
64

Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
11
/// <reference types="vite/client" />
2-
3-
declare module '*.vue' {
4-
import type { DefineComponent } from 'vue'
5-
const component: DefineComponent<{}, {}, any>
6-
export default component
7-
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["Vue.volar"]
2+
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
33
}

packages/create-vite/template-vue/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ This template should help get you started developing with Vue 3 in Vite. The tem
44

55
## Recommended IDE Setup
66

7-
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
7+
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

packages/create-vite/template-vue/src/App.vue

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script setup>
2-
// This starter template is using Vue 3 <script setup> SFCs
3-
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
42
import HelloWorld from './components/HelloWorld.vue'
53
</script>
64

0 commit comments

Comments
 (0)