Skip to content

feat: introduce dtsTsx for TSX support - #673

Merged
antfu merged 6 commits into
unplugin:mainfrom
lishaobos:tsx
Oct 19, 2025
Merged

antfu merged 6 commits into
unplugin:mainfrom
lishaobos:tsx

Conversation

@lishaobos

Copy link
Copy Markdown
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

antfu commented Aug 8, 2023

Copy link
Copy Markdown
Member

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

lishaobos commented Aug 8, 2023 •

Copy link
Copy Markdown
Contributor Author

@antfu i have an idea.

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

@cmdyu

cmdyu commented Sep 14, 2023

Copy link
Copy Markdown

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
Copy Markdown

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.

@wjp980108

Copy link
Copy Markdown

It's been two years, how to solve this problem

@cangSDARM

Copy link
Copy Markdown

any problems? why this pr put on hold

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2025 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unplugin-vue-components@673

commit: d7190da

@antfu antfu changed the title fix: tsx component type declaration feat: introduce dtsTsx for TSX support Oct 19, 2025
@antfu
antfu merged commit 4d6b364 into unplugin:main Oct 19, 2025
8 checks passed
@yanhao98

Copy link
Copy Markdown
image

with dtsTsx: true:

unplugin-icons/resolver:

Previously, the syntax was:
<icon-clarity:language-line />

Now, it can only be written as:
<icon-clarity-language-line />

This was referenced Feb 28, 2026
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.

10 participants