Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Svelte 4 with TypeScript. ParseError: Unexpected token #347

@dmdin

Description

@dmdin

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 🥇

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions