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 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions packages/vuetify/dev/components.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

declare module '@vue/runtime-core' {
export interface GlobalComponents {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
VAlert: typeof import('@/components/VAlert/index')['VAlert']
VApp: typeof import('@/components/VApp/index')['VApp']
VAutocomplete: typeof import('@/components/VAutocomplete/index')['VAutocomplete']
VAvatar: typeof import('@/components/VAvatar/index')['VAvatar']
VBadge: typeof import('@/components/VBadge/index')['VBadge']
VBanner: typeof import('@/components/VBanner/index')['VBanner']
VBreadcrumbs: typeof import('@/components/VBreadcrumbs/index')['VBreadcrumbs']
VBreadcrumbsItem: typeof import('@/components/VBreadcrumbs/index')['VBreadcrumbsItem']
VBtn: typeof import('@/components/VBtn/index')['VBtn']
VBtnToggle: typeof import('@/components/VBtnToggle/index')['VBtnToggle']
VCard: typeof import('@/components/VCard/index')['VCard']
VCardActions: typeof import('@/components/VCard/index')['VCardActions']
VCardSubtitle: typeof import('@/components/VCard/index')['VCardSubtitle']
VCardText: typeof import('@/components/VCard/index')['VCardText']
VCardTitle: typeof import('@/components/VCard/index')['VCardTitle']
VCarousel: typeof import('@/components/VCarousel/index')['VCarousel']
VCarouselItem: typeof import('@/components/VCarousel/index')['VCarouselItem']
VCheckbox: typeof import('@/components/VCheckbox/index')['VCheckbox']
VChip: typeof import('@/components/VChip/index')['VChip']
VColorPicker: typeof import('@/components/VColorPicker/index')['VColorPicker']
VCombobox: typeof import('@/components/VCombobox/index')['VCombobox']
VContainer: typeof import('@/components/VGrid/index')['VContainer']
VDataTable: typeof import('@/labs/VDataTable/index')['VDataTable']
VDialog: typeof import('@/components/VDialog/index')['VDialog']
VDivider: typeof import('@/components/VDivider/index')['VDivider']
VExpansionPanel: typeof import('@/components/VExpansionPanel/index')['VExpansionPanel']
VFooter: typeof import('@/components/VFooter/index')['VFooter']
VForm: typeof import('@/components/VForm/index')['VForm']
VHover: typeof import('@/components/VHover/index')['VHover']
VIcon: typeof import('@/components/VIcon/index')['VIcon']
VImg: typeof import('@/components/VImg/index')['VImg']
VInput: typeof import('@/components/VInput/index')['VInput']
VItem: typeof import('@/components/VItemGroup/index')['VItem']
VItemGroup: typeof import('@/components/VItemGroup/index')['VItemGroup']
VLabel: typeof import('@/components/VLabel/index')['VLabel']
VList: typeof import('@/components/VList/index')['VList']
VListGroup: typeof import('@/components/VList/index')['VListGroup']
VListItem: typeof import('@/components/VList/index')['VListItem']
VMain: typeof import('@/components/VMain/index')['VMain']
VMenu: typeof import('@/components/VMenu/index')['VMenu']
VMessages: typeof import('@/components/VMessages/index')['VMessages']
VNavigationDrawer: typeof import('@/components/VNavigationDrawer/index')['VNavigationDrawer']
VOverlay: typeof import('@/components/VOverlay/index')['VOverlay']
VPagination: typeof import('@/components/VPagination/index')['VPagination']
VProgressCircular: typeof import('@/components/VProgressCircular/index')['VProgressCircular']
VProgressLinear: typeof import('@/components/VProgressLinear/index')['VProgressLinear']
VRadio: typeof import('@/components/VRadio/index')['VRadio']
VRangeSlider: typeof import('@/components/VRangeSlider/index')['VRangeSlider']
VRating: typeof import('@/components/VRating/index')['VRating']
VResponsive: typeof import('@/components/VResponsive/index')['VResponsive']
VSelect: typeof import('@/components/VSelect/index')['VSelect']
VSheet: typeof import('@/components/VSheet/index')['VSheet']
VSlider: typeof import('@/components/VSlider/index')['VSlider']
VSnackbar: typeof import('@/components/VSnackbar/index')['VSnackbar']
VSwitch: typeof import('@/components/VSwitch/index')['VSwitch']
VSystemBar: typeof import('@/components/VSystemBar/index')['VSystemBar']
VTab: typeof import('@/components/VTabs/index')['VTab']
VTabs: typeof import('@/components/VTabs/index')['VTabs']
VTextarea: typeof import('@/components/VTextarea/index')['VTextarea']
VThemeProvider: typeof import('@/components/VThemeProvider/index')['VThemeProvider']
VTimeline: typeof import('@/components/VTimeline/index')['VTimeline']
VTimelineItem: typeof import('@/components/VTimeline/index')['VTimelineItem']
VToolbar: typeof import('@/components/VToolbar/index')['VToolbar']
VToolbarTitle: typeof import('@/components/VToolbar/index')['VToolbarTitle']
VTooltip: typeof import('@/components/VTooltip/index')['VTooltip']
}
}

export {}
Copy link
Member

Choose a reason for hiding this comment

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

Just add this to gitignore, otherwise it'll change every time you modify the playground

Copy link
Member

Choose a reason for hiding this comment

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

also eslintignore

Copy link
Member Author

@yuwu9145 yuwu9145 Mar 9, 2023

Choose a reason for hiding this comment

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

also eslintignore

this file will be ignored by git so it doesn't bother lint command in CI. Assuming this is for IDE experience, then a .eslintignore file should be placed in root directory

1 change: 1 addition & 0 deletions packages/vuetify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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