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

Svelte 4 with TypeScript. ParseError: Unexpected token #347

Open
1 task
dmdin opened this issue Feb 12, 2025 · 1 comment
Open
1 task

Svelte 4 with TypeScript. ParseError: Unexpected token #347

dmdin opened this issue Feb 12, 2025 · 1 comment

Comments

@dmdin
Copy link

dmdin commented Feb 12, 2025

Your Environment

  • Prettier version: 3.3.3
  • node version: v20.12.0
  • package manager: pnpm@10
  • IDE: VScode

Describe the bug

Sorting imports is breaking on types in .svelte files

To Reproduce

  • Svelte file with lang="ts"
  • Type on exported variable

Expected behavior

Sorting works in Svelte files with lang="ts"

Screenshots, code sample, etc

This one breaks

<script lang="ts">
  export let name: string
</script>

And this one works

<script lang="ts">
  export let name
</script>

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

{
  "useTabs": false,
  "tabWidth": 2,
  "singleQuote": true,
  "trailingComma": "es5",
  "bracketSameLine": true,
  "semi": false,
  "printWidth": 80,
  "arrowParens": "always",
  "plugins": ["prettier-plugin-svelte", "@trivago/prettier-plugin-sort-imports"],
  "importOrder": [
    "^@smkit/*",
    "^~icons",
    "^(\\$app)|(\\$env)|(\\$lib)|(\\$ui)",
    "^\\$",
    "^[./]"
  ],
  "importOrderParserPlugins": ["typescript", "decorators-legacy"],
  "importOrderSeparation": true,
  "importOrderSortSpecifiers": true
}

Error log

Image

Contribute to @trivago/prettier-plugin-sort-imports

  • I'm willing to fix this bug 🥇
@dmdin
Copy link
Author

dmdin commented Feb 12, 2025

Seems to be lack of preprocess step

const { instance, module } = parse(code);

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

No branches or pull requests

1 participant