From 9ceaf651aacc35e524e7430e631873ce31a7b9ef Mon Sep 17 00:00:00 2001 From: Yuchao Date: Wed, 22 Mar 2023 01:58:31 +1100 Subject: [PATCH] chore(dev): check component types in playground.vue (#16843) Co-authored-by: Kael --- packages/vuetify/.eslintignore | 5 ++++- packages/vuetify/.gitignore | 1 + packages/vuetify/package.json | 1 + packages/vuetify/tsconfig.dev.json | 8 +++++++- packages/vuetify/vite.config.mjs | 4 ++-- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/vuetify/.eslintignore b/packages/vuetify/.eslintignore index 4f08e7f03fd..e0a4dbe295d 100644 --- a/packages/vuetify/.eslintignore +++ b/packages/vuetify/.eslintignore @@ -1,8 +1,11 @@ /build/ +# playground components type definitions generated by unplugin-vue-components +/dev/components.d.ts + # Built files /es5/ /lib/ /lib-temp/ /dist/ -/cypress/ \ No newline at end of file +/cypress/ diff --git a/packages/vuetify/.gitignore b/packages/vuetify/.gitignore index ca9f5d7d02b..1cdbaeaa2ed 100644 --- a/packages/vuetify/.gitignore +++ b/packages/vuetify/.gitignore @@ -1,4 +1,5 @@ /dev/Playground.vue +/dev/components.d.ts /cypress/screenshots # Built files diff --git a/packages/vuetify/package.json b/packages/vuetify/package.json index 8adca363576..c4175585e1f 100755 --- a/packages/vuetify/package.json +++ b/packages/vuetify/package.json @@ -100,6 +100,7 @@ "dev": "cross-env NODE_ENV=development vite", "dev:ssr": "cross-env NODE_ENV=development VITE_SSR=true vite-ssr", "dev:prod": "concurrently \"cross-env NODE_ENV=production vite build -w\" \"vite preview\"", + "dev:typecheck": "vue-tsc --noEmit --skipLibCheck --project ./tsconfig.dev.json", "build": "rimraf lib dist && concurrently \"yarn build:dist\" \"yarn build:lib\" -n \"dist,lib\" --kill-others-on-fail -r && yarn build:types", "build:dist": "rollup --config build/rollup.config.js", "build:lib": "cross-env NODE_ENV=lib babel src --out-dir lib --source-maps --extensions \".ts\",\".tsx\",\".snap\" --copy-files --no-copy-ignored --out-file-extension .mjs", diff --git a/packages/vuetify/tsconfig.dev.json b/packages/vuetify/tsconfig.dev.json index e5dd2c17fc9..c4fcb09e39e 100644 --- a/packages/vuetify/tsconfig.dev.json +++ b/packages/vuetify/tsconfig.dev.json @@ -4,5 +4,11 @@ "src", "dev", "cypress" - ] + ], + "compilerOptions": { + "allowJs": true + }, + "vueCompilerOptions": { + "strictTemplates": true + } } diff --git a/packages/vuetify/vite.config.mjs b/packages/vuetify/vite.config.mjs index 12245b4ece4..67e41b81be1 100644 --- a/packages/vuetify/vite.config.mjs +++ b/packages/vuetify/vite.config.mjs @@ -20,7 +20,7 @@ const components = files.filter(file => file.startsWith('src/labs') || !block.so const map = new Map(components.flatMap(file => { const src = readFileSync(file, { encoding: 'utf8' }) const matches = src.matchAll(/export const (V\w+)|export { (V\w+) }/gm) - return Array.from(matches, m => [m[1] || m[2], file.replace('src/', '@/')]) + return Array.from(matches, m => [m[1] || m[2], file.replace('src/', '@/').replace('.ts', '')]) })) export default defineConfig(({ mode }) => { @@ -45,7 +45,7 @@ export default defineConfig(({ mode }) => { vueJsx({ optimize: false, enableObjectSlots: true }), viteSSR(), Components({ - dts: false, + dts: true, resolvers: [ name => { if (map.has(name)) {