Skip to content

Index signature for type 'string' is missing in type 'GlobalComponents' #5161

Closed
@jonas-eiselt-fk

Description

@jonas-eiselt-fk

Vue - Official extension or vue-tsc version

vue-tsc: 2.2.0

VSCode version

N/A

Vue version

3.5.13

TypeScript version

5.7.3

System Info

N/A

package.json dependencies

See minimal reproduction

Steps to reproduce

  1. Go to https://stackblitz.com/edit/vitejs-vite-7p6yratb?file=src%2FApp.vue&view=editor
  2. Run npm run build in the terminal (if you get EIO: i/o error, write error, just ignore and proceed to next step)
  3. Run npx vue-tsc --noEmit dist/types/App.vue.d.ts

After last step you hopefully get the error:

dist/types/App.vue.d.ts:7:474 - error TS2344: Type 'GlobalComponents' does not satisfy the constraint 'Record<string, Component<any, any, any, ComputedOptions, MethodOptions, {}, any>>'.
  Index signature for type 'string' is missing in type 'GlobalComponents'.

7         myInput: import("vue").CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in dist/types/App.vue.d.ts:7

What is expected?

I expect CreateComponentPublicInstanceWithMixins to be able to accept GlobalComponents as one of its type arguments (I guess...).

What is actually happening?

I don't know. In the minimal reproduction I have:

  • a base component (BaseInput.vue)
  • a component that extends the base component (ExtendedInput.vue)
  • and another component (App.vue) where I use the extended component with a ref attribute. I also use a slot in the App.vue. Note: If I don't provide a slot in App.vue, "GlobalComponents" in the generated d.ts file doesn't seem to be problematic

"myInput" in generated App.vue.d.ts has the type CreateComponentPublicInstanceWithMixins with GlobalComponents as one of its type arguments.

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-7p6yratb?file=src%2FApp.vue&view=editor

Any additional comments?

The problem doesn't exist in 3.5.0-beta.3. Starts appearing in 3.5.0-rc.1 and 3.5.0.

This commit seems suspicious: vuejs/core@42e8df6
What problem did it solve? No tests were added or edited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions