Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt built-in and auto imported components typed as unknown #4170

Closed
ThomasBerne opened this issue Mar 28, 2024 · 16 comments
Closed

Nuxt built-in and auto imported components typed as unknown #4170

ThomasBerne opened this issue Mar 28, 2024 · 16 comments
Labels
external good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@ThomasBerne
Copy link

I use nuxt 3 and Vue Official 2.X+

Built-in and auto imported components are typed as unknown :

image

Even though they are in the .nuxt/components.d.ts

image

Imported by the .nuxt/tsconfig.json

image

.nuxt/tsconfig.json extended by my project tsconfig.json

image

@johnsoncodehk
Copy link
Member

  1. Are you using 2.0.7?
  2. If yes, is Hybrid Mode enabled?

@ThomasBerne
Copy link
Author

I have tried using. 2.6, 2.7 and insider versions. What is the hybrid mode ? I don't think I use It. I'm all on vue 3.

@so1ve
Copy link
Member

so1ve commented Mar 28, 2024

I can confirm this issue with a fresh nuxt content starter. MarkdownXXX components' type are unknown.

@ThomasBerne
Copy link
Author

Thank you @so1ve I tried a reproduction with a fresh nuxt 3 install but it works like a charm.

@johnsoncodehk
Copy link
Member

Hybrid Mode is an option to improve language server performance.

image

When enabled, it may cause the problem you asked because tsserver selects a different tsconfig for .vue.

FYI: microsoft/TypeScript#57632

@ThomasBerne
Copy link
Author

ThomasBerne commented Mar 28, 2024

Activating or deactivating the hybrid mode doesn't change anything on my side.

@ThomasBerne
Copy link
Author

ThomasBerne commented Mar 28, 2024

I found the problem! It's related to nuxt-typed-router.

when removing this line in the .nuxt/tsconfig.json

image

Everything works fine.

@ThomasBerne ThomasBerne changed the title Nuxt unknown built in auto imported component Nuxt built-in and auto imported components typed as unknown Mar 28, 2024
@johnsoncodehk johnsoncodehk added bug Something isn't working need info and removed need info bug Something isn't working labels Mar 28, 2024
@johnsoncodehk
Copy link
Member

johnsoncodehk commented Mar 28, 2024

@ThomasBerne I tried using nuxt-typed-router with a newly created project but could not reproduce the problem, can you see if there is any difference?

reproduction: https://github.com/johnsoncodehk/issue-4170-repro

@ThomasBerneHCSE
Copy link

Indeed i cannot reproduce either with only the nuxt typed router package. This must be a collision of nuxt packages I guess. I'll try to reproduce it.

@ThomasBerneHCSE
Copy link

I successfully reproduced adding vuetify and nuxt typed router to a clear nuxt install :
https://github.com/ThomasBerneHCSE/issue-4170-repro

I used npm as the default package manager.

@ThomasBerneHCSE
Copy link

You can see the problem in the pages/[id]/index.vue

@johnsoncodehk
Copy link
Member

I tried locally and in Codespace but couldn't reproduce (using npm).

image

@ThomasBerneHCSE
Copy link

ThomasBerneHCSE commented Mar 28, 2024

VApp exists. It has to problems sorry. But the Test component is marked as unknown
image
image

@ThomasBerneHCSE
Copy link

Like if vuetify was overwriting GlobalComponents definition. But only when it is installed alongside of the nuxt-typed-router package.

@johnsoncodehk
Copy link
Member

Confirmed. 👍

@johnsoncodehk johnsoncodehk added pending triage good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first and removed need info labels Mar 28, 2024
@johnsoncodehk
Copy link
Member

johnsoncodehk commented Mar 28, 2024

I think this problem needs to be solved by Nuxt, currently Nuxt generates GlobalComponents as:

declare module 'vue' {
	export interface GlobalComponents {
		Test: (typeof import('../components/Test.vue'))['default'];
	}
}

To avoid types being overwritten in the npm node_modules structure, it should probably be generated as:

interface _GlobalComponents {
	Test: (typeof import('../components/Test.vue'))['default'];
}

declare module '@vue/runtime-core' {
	export interface GlobalComponents extends _GlobalComponents { };
}

declare module '@vue/runtime-dom' {
	export interface GlobalComponents extends _GlobalComponents { };
}

declare module 'vue' {
	export interface GlobalComponents extends _GlobalComponents { };
}

@danielroe can you or someone take up this issue? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

4 participants