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

fix: tsx component type declaration #673

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

lishaobos
Copy link
Contributor

Description

make auto imported component work with tsx

Linked Issues

#669

Additional context

@lishaobos lishaobos requested a review from antfu as a code owner August 7, 2023 10:41
@antfu
Copy link
Member

antfu commented Aug 8, 2023

It should be done under a flag. As it provides global types, while this plugin only transform Vue's complication result, which will create misalignment between types and actual behaviour

@lishaobos
Copy link
Contributor Author

lishaobos commented Aug 8, 2023

@antfu i have an idea.

  1. add options.dtsGlobal: boolean
  2. add options.dts type: boolean | string | { path: string; global: boolean }

@cmdyu
Copy link

cmdyu commented Sep 14, 2023

I solved the problem in this way:

created a 'components-tsc.d.ts' file manually

export {}

declare global {
    const NButton: typeof import('naive-ui')['NButton']
}

and put it in the tsconfig.json's include prop

{
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "auto-imports.d.ts", "components-tsx.d.ts"],
  ...
}

@whaaaley
Copy link

I was curious if there's anything I could do to help get this merged. I've been struggling with types in this way for some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants