From: nandi95 <41805560+nandi95@users.noreply.github.com> Date: Wed, 26 Oct 2022 09:00:47 +0000 (+0100) Subject: types(runtime-core): added `ComponentCustomProperties` type to `globalProperties... X-Git-Tag: v3.2.42~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=506a42a9a5782b6cd297a8f4b9679db51b7aacff;p=thirdparty%2Fvuejs%2Fcore.git types(runtime-core): added `ComponentCustomProperties` type to `globalProperties` (#5389) --- diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index dbf71951b1..1c588dbc8f 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -11,7 +11,10 @@ import { MergedComponentOptions, RuntimeCompilerOptions } from './componentOptions' -import { ComponentPublicInstance } from './componentPublicInstance' +import { + ComponentCustomProperties, + ComponentPublicInstance +} from './componentPublicInstance' import { Directive, validateDirectiveName } from './directives' import { RootRenderFunction } from './renderer' import { InjectionKey } from './apiInject' @@ -70,7 +73,7 @@ export interface AppConfig { performance: boolean optionMergeStrategies: Record - globalProperties: Record + globalProperties: ComponentCustomProperties & Record errorHandler?: ( err: unknown, instance: ComponentPublicInstance | null, diff --git a/test-dts/componentTypeExtensions.test-d.tsx b/test-dts/componentTypeExtensions.test-d.tsx index 3ff5b7addb..e26c272c70 100644 --- a/test-dts/componentTypeExtensions.test-d.tsx +++ b/test-dts/componentTypeExtensions.test-d.tsx @@ -6,7 +6,7 @@ declare module '@vue/runtime-core' { } interface ComponentCustomProperties { - state: 'stopped' | 'running' + state?: 'stopped' | 'running' } interface ComponentCustomProps { @@ -35,6 +35,14 @@ export const Custom = defineComponent({ expectError(this.notExisting) this.counter++ this.state = 'running' + + this.$.appContext.config.globalProperties.state = 'running' + + expectError( + // @ts-expect-error + (this.$.appContext.config.globalProperties.state = 'not valid') + ) + // @ts-expect-error expectError((this.state = 'not valid')) }