Skip to content

Semicolon is added when organize import in specific case #50817

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

Closed
orblazer opened this issue Sep 17, 2022 · 1 comment
Closed

Semicolon is added when organize import in specific case #50817

orblazer opened this issue Sep 17, 2022 · 1 comment
Labels
Not a Defect This behavior is one of several equally-correct options

Comments

@orblazer
Copy link

Bug Report

🔎 Search Terms

  • Semicolon organize import
  • Semicolon vscode

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about semicolon organize import

💻 Code

import { resolve } from "path"

type test = { var1: number; var2: string }

console.log(resolve(__dirname))

Vscode config (settings.json) :

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.organizeImports": true
    // "source.sortImports": true // This also append when this is enabled
  },
  "typescript.tsdk": "./node_modules/typescript/lib"
}

Prettier config (.prettierrc)

{
  "semi": false
}

🙁 Actual behavior

When i save file, this add semicolon on all import.

🙂 Expected behavior

No add semicolon on import.

Additional information

That issue ONLY append when i have an type write like that { var1: number; var2: string }, so i think the organize/sort (maybe from here #31801) think the semicolon is used because is present in code.

@RyanCavanaugh RyanCavanaugh added the Not a Defect This behavior is one of several equally-correct options label Sep 20, 2022
@RyanCavanaugh
Copy link
Member

TypeScript doesn't know about prettier and uses a heuristic to figure out it if seems like you're using semicolons or not. Since you could have used a comma to separate var1 and var2, this appears to be a "semicolon-friendly" codebase based on that heuristic.

Set the "Semicolons" formatter option according to your formatting style:
image

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Defect This behavior is one of several equally-correct options
Projects
None yet
Development

No branches or pull requests

2 participants