mirror of https://github.com/vuejs/core.git
types(runtime-core): added `ComponentCustomProperties` type to `globalProperties` (#5389)
This commit is contained in:
parent
83f7e6f8a6
commit
506a42a9a5
|
@ -11,7 +11,10 @@ import {
|
||||||
MergedComponentOptions,
|
MergedComponentOptions,
|
||||||
RuntimeCompilerOptions
|
RuntimeCompilerOptions
|
||||||
} from './componentOptions'
|
} from './componentOptions'
|
||||||
import { ComponentPublicInstance } from './componentPublicInstance'
|
import {
|
||||||
|
ComponentCustomProperties,
|
||||||
|
ComponentPublicInstance
|
||||||
|
} from './componentPublicInstance'
|
||||||
import { Directive, validateDirectiveName } from './directives'
|
import { Directive, validateDirectiveName } from './directives'
|
||||||
import { RootRenderFunction } from './renderer'
|
import { RootRenderFunction } from './renderer'
|
||||||
import { InjectionKey } from './apiInject'
|
import { InjectionKey } from './apiInject'
|
||||||
|
@ -70,7 +73,7 @@ export interface AppConfig {
|
||||||
|
|
||||||
performance: boolean
|
performance: boolean
|
||||||
optionMergeStrategies: Record<string, OptionMergeFunction>
|
optionMergeStrategies: Record<string, OptionMergeFunction>
|
||||||
globalProperties: Record<string, any>
|
globalProperties: ComponentCustomProperties & Record<string, any>
|
||||||
errorHandler?: (
|
errorHandler?: (
|
||||||
err: unknown,
|
err: unknown,
|
||||||
instance: ComponentPublicInstance | null,
|
instance: ComponentPublicInstance | null,
|
||||||
|
|
|
@ -6,7 +6,7 @@ declare module '@vue/runtime-core' {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ComponentCustomProperties {
|
interface ComponentCustomProperties {
|
||||||
state: 'stopped' | 'running'
|
state?: 'stopped' | 'running'
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ComponentCustomProps {
|
interface ComponentCustomProps {
|
||||||
|
@ -35,6 +35,14 @@ export const Custom = defineComponent({
|
||||||
expectError(this.notExisting)
|
expectError(this.notExisting)
|
||||||
this.counter++
|
this.counter++
|
||||||
this.state = 'running'
|
this.state = 'running'
|
||||||
|
|
||||||
|
this.$.appContext.config.globalProperties.state = 'running'
|
||||||
|
|
||||||
|
expectError(
|
||||||
|
// @ts-expect-error
|
||||||
|
(this.$.appContext.config.globalProperties.state = 'not valid')
|
||||||
|
)
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
expectError((this.state = 'not valid'))
|
expectError((this.state = 'not valid'))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue