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

Typescript typecasting generic function reports missing semicolon #267

Open
1 task
puzzler7 opened this issue Oct 27, 2023 · 0 comments
Open
1 task

Typescript typecasting generic function reports missing semicolon #267

puzzler7 opened this issue Oct 27, 2023 · 0 comments

Comments

@puzzler7
Copy link

puzzler7 commented Oct 27, 2023

Your Environment

  • Prettier version: 3.0.3
  • node version: v18.15.0
  • package manager: [email protected]
  • IDE: CLI

Describe the bug

When formatting Typescript, prettier reports there is a missing semicolon in the middle of typecasting a generic function. Specifically, it reports that there should be a semicolon before the as in this code:

function func<T>() {};
const x = func<number> as any;

This error does not happen if the @trivago/prettier-plugin-sort-imports plugin is not included.

To Reproduce
Run prettier on the above code snippet with @trivago/prettier-plugin-sort-imports installed.

Expected behavior

Prettier should output no errors.

Screenshots, code sample, etc

Minimal repro - repro.ts:

function func<T>() {};
const x = func<number> as any;

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

$ cat .prettierrc.yaml 
printWidth: 100
proseWrap: always
plugins: ["@trivago/prettier-plugin-sort-imports"]
importOrder:
  ["^reflect-metadata$", "(firebase-auth-mock|logrocket-mock)$", "<THIRD_PARTY_MODULES>", "^[./]"]
importOrderCaseInsensitive: true
importOrderParserPlugins: ["typescript", "jsx", "decorators-legacy"]
importOrderSeparation: true
importOrderSortSpecifiers: true

Error log

$ prettier -c repro.ts
Checking formatting...
repro.ts
[error] repro.ts: SyntaxError: Missing semicolon. (2:25)
All matched files use Prettier code style!

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

  • I'm willing to fix this bug 🥇
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