Skip to content

VueTestUtilsConfigOptions provide type is not allowing symbols as keys #2108

@DesselBane

Description

@DesselBane

Subject of the issue

When defining global provides using a Symbol / vues InjectionKey<T> type there is a type error.

Steps to reproduce

const testKey: InjectionKey<string> = Symbol("testKey");

config.global.provide[testKey] = "testValue";
// Type 'InjectionKey<string>' cannot be used as an index type.ts(2538)

Expected behaviour

Symbols should be supported in the type, as they work at runtime.

Actual behaviour

TS Error

Possible Solution

provide?: Record<string, any>,

I think changing the type here would suffice

// Currently
export interface VueTestUtilsConfigOptions {
  stubs: Record<string, Component | boolean | string>
  mocks: Record<string, any>
  methods: Record<string, Function>
  provide?: Record<string, any>,
  showDeprecationWarnings?: boolean
  deprecationWarningHandler?: Function
}

// Fixed
export interface VueTestUtilsConfigOptions {
  stubs: Record<string, Component | boolean | string>
  mocks: Record<string, any>
  methods: Record<string, Function>
  provide?: Record<string | symbol, any>,
  showDeprecationWarnings?: boolean
  deprecationWarningHandler?: Function
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions