Skip to content

Commit

Permalink
feat(types): emit declarations as .d.mts
Browse files Browse the repository at this point in the history
closes #15885

BREAKING CHANGE: .d.ts imports have to be changed to .d.mts
BREAKING CHANGE: minimum typescript version 4.7
  • Loading branch information
KaelWD committed May 10, 2023
1 parent b8a9398 commit 5e08832
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/api-generator/templates/composables.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type vuetify from '../../vuetify/lib/index'
import type vuetify from '../../vuetify/lib/index.d.mts'

type IsComposable<T extends string | number | symbol> = T extends `use${Capitalize<infer _>}` ? T : never;

Expand Down
2 changes: 1 addition & 1 deletion packages/api-generator/templates/directives.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DirectiveBinding } from 'vue'
import type * as directives from '../../vuetify/lib/directives/index'
import type * as directives from '../../vuetify/lib/directives/index.d.mts'

type ExtractDirectiveBindings<T> = T extends object
? {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-generator/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"strict": false,
"noUnusedLocals": false,
"module": "ESNext",
"moduleResolution": "NodeNext",
"moduleResolution": "bundler",
"noEmitOnError": false,
"resolveJsonModule": true,
"paths": {
Expand Down
22 changes: 11 additions & 11 deletions packages/vuetify/build/rollup.types.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function getShims () {
}

export default [
createTypesConfig('framework.d.ts', 'lib/index.d.ts', async code => {
createTypesConfig('framework.d.ts', 'lib/index.d.mts', async code => {
code.append('\n\n')
code.append(await getShims())
}),
Expand All @@ -87,21 +87,21 @@ export default [
code.append('\n\n')
code.append((await getShims()).replace(', VNodeChild } from \'vue\'', ' } from \'vue\''))
}),
createTypesConfig('blueprints/*.d.ts', 'lib/blueprints/*.d.ts'),
createTypesConfig('components/index.d.ts', 'lib/components/index.d.ts'),
createTypesConfig('components/*/index.d.ts', 'lib/components/*/index.d.ts', undefined, files => {
createTypesConfig('blueprints/*.d.ts', 'lib/blueprints/*.d.mts'),
createTypesConfig('components/index.d.ts', 'lib/components/index.d.mts'),
createTypesConfig('components/*/index.d.ts', 'lib/components/*/index.d.mts', undefined, files => {
const index = readFileSync(fileURLToPath(new URL('../src/components/index.ts', import.meta.url)), { encoding: 'utf8' })
const block = Array.from(index.matchAll(/^\/\/ export \* from '\.\/(.*)'$/gm), m => m[1])
return files.filter(file => !block.some(name => file.includes(`/${name}/`)))
}),
createTypesConfig('labs/entry-bundler.d.ts', 'dist/vuetify-labs.d.ts', code => {
code.replaceAll(/type allComponents_d_V(\w+) = V(\w+);/gm, 'declare const allComponents_d_V$1: typeof V$2;')
}),
createTypesConfig('labs/components.d.ts', 'lib/labs/components.d.ts'),
createTypesConfig('labs/*/index.d.ts', 'lib/labs/*/index.d.ts'),
createTypesConfig('labs/date/adapters/*.d.ts', 'lib/labs/date/adapters/*.d.ts'),
createTypesConfig('directives/index.d.ts', 'lib/directives/index.d.ts'),
createTypesConfig('locale/index.d.ts', 'lib/locale/index.d.ts'),
createTypesConfig('locale/adapters/*.d.ts', 'lib/locale/adapters/*.d.ts'),
createTypesConfig('iconsets/*.d.ts', 'lib/iconsets/*.d.ts'),
createTypesConfig('labs/components.d.ts', 'lib/labs/components.d.mts'),
createTypesConfig('labs/*/index.d.ts', 'lib/labs/*/index.d.mts'),
createTypesConfig('labs/date/adapters/*.d.ts', 'lib/labs/date/adapters/*.d.mts'),
createTypesConfig('directives/index.d.ts', 'lib/directives/index.d.mts'),
createTypesConfig('locale/index.d.ts', 'lib/locale/index.d.mts'),
createTypesConfig('locale/adapters/*.d.ts', 'lib/locale/adapters/*.d.mts'),
createTypesConfig('iconsets/*.d.ts', 'lib/iconsets/*.d.mts'),
].flat()
14 changes: 9 additions & 5 deletions packages/vuetify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"module": "lib/framework.mjs",
"jsdelivr": "dist/vuetify.js",
"unpkg": "dist/vuetify.js",
"types": "lib/index.d.ts",
"types": "lib/index.d.mts",
"sass": "lib/styles/main.sass",
"styles": "lib/styles/main.css",
"sideEffects": [
Expand Down Expand Up @@ -79,17 +79,17 @@
"typesVersions": {
"*": {
"lib/framework.mjs": [
"lib/index.d.ts"
"lib/index.d.mts"
],
"framework": [
"lib/index.d.ts"
"lib/index.d.mts"
],
"*": [
"*",
"dist/*",
"lib/*",
"lib/*.d.ts",
"lib/*/index.d.ts"
"lib/*.d.mts",
"lib/*/index.d.mts"
]
}
},
Expand Down Expand Up @@ -167,12 +167,16 @@
"vue-router": "^4.1.6"
},
"peerDependencies": {
"typescript": ">=4.7",
"vite-plugin-vuetify": "^1.0.0-alpha.12",
"vue": "^3.2.0",
"vue-i18n": "^9.0.0",
"webpack-plugin-vuetify": "^2.0.0-alpha.11"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
},
"vue-i18n": {
"optional": true
},
Expand Down

0 comments on commit 5e08832

Please sign in to comment.