Skip to content

fix: add getScriptKind to host for Vue JSX/TSX support#160

Open
susanforme wants to merge 1 commit into
simonhaenisch:masterfrom
susanforme:fix/vue-jsx-script-kind
Open

fix: add getScriptKind to host for Vue JSX/TSX support#160
susanforme wants to merge 1 commit into
simonhaenisch:masterfrom
susanforme:fix/vue-jsx-script-kind

Conversation

@susanforme

Copy link
Copy Markdown

Fix: not working for Vue files with <script lang="jsx"> or <script lang="tsx">

Problem

When using prettier-plugin-organize-imports with Vue files that have <script lang="jsx"> or <script lang="tsx">, unused imports are not removed and import sorting may silently fail.

Root Cause

During decoration, Volar's decorateLanguageServiceHost checks whether the host provides a getScriptKind method. If this method is missing, Volar skips overriding getScriptKind, which means TypeScript has no way to know that a virtual file generated from <script lang="jsx"> should be parsed as JSX.

TypeScript then defaults to treating the content as plain TS, fails to parse JSX syntax like <div>, and organizeImports returns an empty array — so no imports get removed.

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.

1 participant