Skip to content

Commit

Permalink
fix: vue app typing (element-plus#8137)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Jun 7, 2022
1 parent b34ca0f commit edaa6f6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './aria'
export * from './date'
export * from './event'
export * from './key'
export * from './size'
1 change: 1 addition & 0 deletions packages/constants/key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const INSTALLED_KEY = Symbol('INSTALLED_KEY')
2 changes: 1 addition & 1 deletion packages/element-plus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions packages/element-plus/make-installer.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.web.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions typings/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { vShow } from 'vue'
import type { INSTALLED_KEY } from '@element-plus/constants'

declare global {
const process: {
Expand All @@ -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
}
Expand Down

0 comments on commit edaa6f6

Please sign in to comment.