Skip to content

Commit

Permalink
refactor: rearranged TS configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Uninen committed Dec 29, 2023
1 parent a5aa9d5 commit 79337ef
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 72 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
root: true,
extends: [
'plugin:vue/vue3-recommended',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting',
'plugin:security/recommended',
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
/**
* Automatically read from package.json version field
*/
readonly VITE_APP_VERSION: string
readonly VITE_APP_BUILD_EPOCH?: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
20 changes: 20 additions & 0 deletions interface-extensions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Router } from 'vue-router'
import 'vue-router'
import 'pinia'

export {}

declare module 'vue-router' {
interface RouteMeta {
title?: string
}
}

declare module 'pinia' {
export interface PiniaCustomProperties {
/**
* Vue Router instance
*/
router: Router
}
}
34 changes: 0 additions & 34 deletions src/env.d.ts

This file was deleted.

12 changes: 12 additions & 0 deletions teconfig.vitest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.app.json",
"exclude": [],
"compilerOptions": {
"composite": true,
"lib": [],
"types": [
"node",
"jsdom"
]
}
}
20 changes: 20 additions & 0 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": [
"env.d.ts",
"interface-extensions.d.ts",
"components.d.ts",
"auto-imports.d.ts",
"src/**/*",
"src/**/*.vue"
],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
40 changes: 11 additions & 29 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,

/* Paths */
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
"files": [],
"references": [
{

Check failure on line 4 in tsconfig.json

View workflow job for this annotation

GitHub Actions / tests

Referenced project '/home/runner/work/vite-ts-tailwind-starter/vite-ts-tailwind-starter/tsconfig.node.json' may not disable emit.
"path": "./tsconfig.node.json"
},
{

Check failure on line 7 in tsconfig.json

View workflow job for this annotation

GitHub Actions / tests

Referenced project '/home/runner/work/vite-ts-tailwind-starter/vite-ts-tailwind-starter/tsconfig.app.json' may not disable emit.
"path": "./tsconfig.app.json"
},
{

Check failure on line 10 in tsconfig.json

View workflow job for this annotation

GitHub Actions / tests

File '/home/runner/work/vite-ts-tailwind-starter/vite-ts-tailwind-starter/tsconfig.vitest.json' not found.
"path": "./tsconfig.vitest.json"
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue", "tests/**/*.ts"],
"exclude": ["node_modules", "dist", "public"],
"references": [{ "path": "./tsconfig.node.json" }]
]
}
13 changes: 6 additions & 7 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"include": ["vite.config.*", "vitest.config.*", "playwright.config.*"],
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"noEmit": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"types": ["node", "jsdom"]
},
"include": ["vite.config.ts", "vitest.config.ts", "playwright.config.ts", "package.json"]
"moduleResolution": "Bundler",
"types": ["node"]
}
}
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export default defineConfig({
'@vueuse/head': ['useHead'],
},
],
dts: 'src/auto-imports.d.ts',
dts: 'auto-imports.d.ts',
vueTemplate: true,
eslintrc: {
enabled: true,
},
}),
Components({
dts: 'src/components.d.ts',
dts: 'components.d.ts',
}),
],
resolve: {
Expand Down

0 comments on commit 79337ef

Please sign in to comment.