Skip to content

Commit

Permalink
Merge pull request #2 from gigioSouza/main
Browse files Browse the repository at this point in the history
Test release
  • Loading branch information
sougiovn authored Aug 20, 2021
2 parents b65d961 + 9d3cd91 commit a1f4df7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
27 changes: 0 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +0,0 @@
# Vue 3 + Typescript + Vite

This template should help get you started developing with Vue 3 and Typescript in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur). Make sure to enable `vetur.experimental.templateInterpolationService` in settings!

### If Using `<script setup>`

[`<script setup>`](https://github.com/vuejs/rfcs/pull/227) is a feature that is currently in RFC stage. To get proper IDE support for the syntax, use [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) instead of Vetur (and disable Vetur).

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

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 use the following:

### If Using Volar

Run `Volar: Switch TS Plugin on/off` from VSCode command palette.

### If Using Vetur

1. Install and add `@vuedx/typescript-plugin-vue` to the [plugins section](https://www.typescriptlang.org/tsconfig#plugins) in `tsconfig.json`
2. Delete `src/shims-vue.d.ts` as it is no longer needed to provide module info to Typescript
3. Open `src/main.ts` in VSCode
4. Open the VSCode command palette
5. Search and run "Select TypeScript version" -> "Use workspace version"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview",
"tauri:dev": "tauri dev"
"tauri:dev": "tauri dev",
"tauri:build": "tauri build"
},
"dependencies": {
"pinia": "2.0.0-rc.6",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"lib": ["esnext", "dom"],
"types": [
"vite-plugin-pages/client",
"vite-plugin-vue-layouts/client"
]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "vite-plugin-vue-layouts.d.ts"],
"exclude": ["node_modules", "dist"]
}
12 changes: 12 additions & 0 deletions vite-plugin-vue-layouts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare module 'layouts-generated' {
import { RouteRecordRaw } from 'vue-router'
export function setupLayouts(routes: RouteRecordRaw[]): RouteRecordRaw[]
}

declare module 'virtual:generated-layouts' {
import { RouteRecordRaw } from 'vue-router'
import { Component } from 'vue'
export function setupLayouts(routes: RouteRecordRaw[]): RouteRecordRaw[]
export function createRouterLayout(
resolve: (layoutName: string) => Promise<Component | { default: Component }>): Promise<Component | { default: Component }>
}

0 comments on commit a1f4df7

Please sign in to comment.