Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dev): check component types in playground.vue #16843

Merged
merged 9 commits into from Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion 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/
/cypress/
1 change: 1 addition & 0 deletions packages/vuetify/.gitignore
@@ -1,4 +1,5 @@
/dev/Playground.vue
/dev/components.d.ts
/cypress/screenshots

# Built files
Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/package.json
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion packages/vuetify/tsconfig.dev.json
Expand Up @@ -4,5 +4,11 @@
"src",
"dev",
"cypress"
]
],
"compilerOptions": {
"allowJs": true
},
"vueCompilerOptions": {
"strictTemplates": true
}
}
4 changes: 2 additions & 2 deletions packages/vuetify/vite.config.mjs
Expand Up @@ -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', '')])
Copy link
Member Author

@yuwu9145 yuwu9145 Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To assist vue-tsc work properly, have to remove .ts suffix for import paths, so unplugin-vue-components can yield

VBtn: typeof import('@/components/VBtn/index')['VBtn'] 👍
as opposed to
VBtn: typeof import('@/components/VBtn/index.ts')['VBtn'] 👎

TS 4.x does not support .ts suffix in import path, and it looks like to be one of tasks in TS 5.x roadmap

Issue: microsoft/TypeScript#37582
PR: microsoft/TypeScript#51669

More importantly, this change does not break yarn dev

}))

export default defineConfig(({ mode }) => {
Expand All @@ -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)) {
Expand Down