Skip to content

Semicolon is added when organize import in specific case聽#50817

Closed as not planned

Description

@orblazer

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.

Activity

  1. RyanCavanaugh commented on Sep 20, 2022

    @RyanCavanaugh
    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

  2. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions