Skip to content

Commit 85f673e

Browse files
KaelWDblalan05
authored andcommitted
fix(types): only augment module 'vue'
nuxt/nuxt#28542
1 parent bc11af2 commit 85f673e

File tree

6 files changed

+48
-34
lines changed

6 files changed

+48
-34
lines changed

packages/vuetify/build/rollup.types.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async function getShims () {
8383
)).join('\n')
8484

8585
return (await fs.readFile(fileURLToPath(new URL('../src/shims.d.ts', import.meta.url)), { encoding: 'utf8' }))
86-
.replaceAll(/^\s*\/\/ @skip-build\s+.*$/gm, '')
86+
.replaceAll(/^\s*\/\/ @skip-build\s[\s\S]*?\s$/gm, '')
8787
.replace(/^\s*\/\/ @generate-components$/gm, components)
8888
}
8989

packages/vuetify/cypress/templates/generateStories.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* Utilities for generating formatted mount functions
33
* Some utility functions for mounting these generated examples inside of tests
44
*/
5-
import { FunctionalComponent, JSXComponent } from 'vue'
5+
import { FunctionalComponent } from 'vue'
6+
import { JSXComponent } from '@/composables'
67

78
const _ = Cypress._
89

packages/vuetify/src/composables/icons.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { computed, inject, unref } from 'vue'
66
import { consoleWarn, defineComponent, genericComponent, mergeDeep, propsFactory } from '@/util'
77

88
// Types
9-
import type { InjectionKey, JSXComponent, PropType, Ref } from 'vue'
9+
import type { ComponentPublicInstance, FunctionalComponent, InjectionKey, PropType, Ref } from 'vue'
10+
11+
export type JSXComponent<Props = any> =
12+
| { new (): ComponentPublicInstance<Props> }
13+
| FunctionalComponent<Props>
1014

1115
export type IconValue =
1216
| string

packages/vuetify/src/composables/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export type { DefaultsInstance } from './defaults'
1616
export type { DisplayBreakpoint, DisplayInstance, DisplayThresholds } from './display'
1717
export type { SubmitEventPromise } from './form'
1818
export type { GoToInstance } from './goto'
19-
export type { IconAliases, IconProps, IconSet, IconOptions } from './icons'
19+
export type { IconAliases, IconProps, IconSet, IconOptions, JSXComponent } from './icons'
2020
export type { LocaleInstance, LocaleMessages, RtlInstance, LocaleOptions, RtlOptions } from './locale'
2121
export type { ThemeDefinition, ThemeInstance } from './theme'

packages/vuetify/src/globals.d.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import 'vue/jsx'
22

33
// Types
4-
import type { Events, VNode } from 'vue'
4+
import type { ComponentInjectOptions, ComponentOptionsMixin, EmitsOptions, SlotsType } from 'vue'
5+
import type { ComputedOptions, Events, MethodOptions, VNode } from 'vue'
56
import type { TouchStoredHandlers } from './directives/touch'
67

78
declare global {
@@ -98,7 +99,7 @@ declare global {
9899
}
99100
}
100101

101-
declare module '@vue/runtime-core' {
102+
declare module 'vue' {
102103
export interface ComponentCustomProperties {
103104
_: ComponentInternalInstance
104105
}
@@ -112,8 +113,21 @@ declare module '@vue/runtime-core' {
112113
aliasName?: string
113114
}
114115

115-
// eslint-disable-next-line max-len
116-
export interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string, Defaults = {}> {
116+
export interface ComponentOptionsBase<
117+
Props,
118+
RawBindings,
119+
D,
120+
C extends ComputedOptions,
121+
M extends MethodOptions,
122+
Mixin extends ComponentOptionsMixin,
123+
Extends extends ComponentOptionsMixin,
124+
E extends EmitsOptions,
125+
EE extends string = string,
126+
Defaults = {},
127+
I extends ComponentInjectOptions = {},
128+
II extends string = string,
129+
S extends SlotsType = {}
130+
> {
117131
aliasName?: string
118132
}
119133

@@ -125,9 +139,7 @@ declare module '@vue/runtime-core' {
125139
ctx: ComponentInternalInstance | null
126140
ssContent: VNode | null
127141
}
128-
}
129142

130-
declare module '@vue/runtime-dom' {
131143
type UnionToIntersection<U> =
132144
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never
133145

packages/vuetify/src/shims.d.ts

+21-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
/* eslint-disable local-rules/sort-imports */
22

33
import 'vue/jsx'
4-
import type { FunctionalComponent, UnwrapNestedRefs, VNodeChild } from 'vue'
4+
import type { UnwrapNestedRefs, VNodeChild } from 'vue'
55

6+
// These already exist in scope in the final bundle
67
// @skip-build
7-
import type { ComponentPublicInstance } from 'vue'
8-
9-
// @skip-build
10-
import type { DateInstance, DefaultsInstance, DisplayInstance, IconOptions, LocaleInstance, RtlInstance, ThemeInstance } from './framework'
8+
import type {
9+
DateInstance,
10+
DefaultsInstance,
11+
DisplayInstance,
12+
IconOptions,
13+
LocaleInstance,
14+
RtlInstance,
15+
ThemeInstance,
16+
} from './framework'
1117

1218
declare global {
1319
namespace JSX {
@@ -16,25 +22,8 @@ declare global {
1622
}
1723
}
1824
}
19-
interface _GlobalComponents {
20-
// @generate-components
21-
}
22-
declare module 'vue' {
23-
export type JSXComponent<Props = any> = { new (): ComponentPublicInstance<Props> } | FunctionalComponent<Props>
24-
export interface GlobalComponents extends _GlobalComponents {}
25-
}
2625

27-
declare module '@vue/runtime-dom' {
28-
export interface HTMLAttributes {
29-
$children?: VNodeChild
30-
}
31-
export interface SVGAttributes {
32-
$children?: VNodeChild
33-
}
34-
export interface GlobalComponents extends _GlobalComponents {}
35-
}
36-
37-
declare module '@vue/runtime-core' {
26+
declare module 'vue' {
3827
interface Vuetify {
3928
defaults: DefaultsInstance
4029
display: UnwrapNestedRefs<DisplayInstance>
@@ -47,5 +36,13 @@ declare module '@vue/runtime-core' {
4736
export interface ComponentCustomProperties {
4837
$vuetify: Vuetify
4938
}
50-
export interface GlobalComponents extends _GlobalComponents {}
39+
export interface HTMLAttributes {
40+
$children?: VNodeChild
41+
}
42+
export interface SVGAttributes {
43+
$children?: VNodeChild
44+
}
45+
export interface GlobalComponents {
46+
// @generate-components
47+
}
5148
}

0 commit comments

Comments
 (0)