fix: vue app typing (#8137)

closes #8122
This commit is contained in:
三咲智子 2022-06-07 13:44:57 +08:00 committed by GitHub
parent b34ca0fb0c
commit edaa6f6bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,5 @@
export * from './aria'
export * from './date'
export * from './event'
export * from './key'
export * from './size'

View File

@ -0,0 +1 @@
export const INSTALLED_KEY = Symbol('INSTALLED_KEY')

View File

@ -4,7 +4,7 @@ export * from '@element-plus/constants'
export * from '@element-plus/directives'
export * from '@element-plus/hooks'
export * from '@element-plus/tokens'
export { makeInstaller } from './make-installer'
export * from './make-installer'
export const install = installer.install
export const version = installer.version

View File

@ -1,16 +1,9 @@
import { provideGlobalConfig } from '@element-plus/hooks'
import { INSTALLED_KEY } from '@element-plus/constants'
import { version } from './version'
import type { App, Plugin } from '@vue/runtime-core'
import type { ConfigProviderContext } from '@element-plus/tokens'
const INSTALLED_KEY = Symbol('INSTALLED_KEY')
declare module '@vue/runtime-core' {
interface App {
[INSTALLED_KEY]?: boolean
}
}
export const makeInstaller = (components: Plugin[] = []) => {
const install = (app: App, options?: ConfigProviderContext) => {
if (app[INSTALLED_KEY]) return

View File

@ -6,7 +6,7 @@
"lib": ["ES2018", "DOM", "DOM.Iterable"],
"types": ["unplugin-vue-define-options"]
},
"include": ["packages", "typings/components.d.ts", "env.d.ts"],
"include": ["packages", "typings/components.d.ts", "typings/env.d.ts"],
"exclude": [
"node_modules",
"**/dist",

5
typings/env.d.ts vendored
View File

@ -1,4 +1,5 @@
import type { vShow } from 'vue'
import type { INSTALLED_KEY } from '@element-plus/constants'
declare global {
const process: {
@ -16,6 +17,10 @@ declare global {
}
declare module '@vue/runtime-core' {
export interface App {
[INSTALLED_KEY]?: boolean
}
export interface GlobalComponents {
Component: (props: { is: Component | string }) => void
}