Skip to content

Broken comment spacing with IIFE and"semicolons": "asi" #771

@bladeSk

Description

@bladeSk

Describe the bug
The semicolon, which is required in between a statement and an IIFE seems to trip up the TS plugin and it messes up spacing - see below.

dprint-plugin-typescript version: 0.95.13

config used:

{
  "typescript": {
    "semiColons": "asi"
  },
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.95.13.wasm"
  ]
}

Input Code

import { createRoot } from "react-dom/client"

/**
 * Initializes the app
 */
;(function initReact() {
  const root = createRoot(document.getElementById("root")!)
  root.render(<div>hello</div>)
})()

Expected Output

same as input

Actual Output

import { createRoot } from "react-dom/client" /**
 * Initializes the app
 */
;(function initReact() {
  const root = createRoot(document.getElementById("root")!)
  root.render(<div>hello</div>)
})()

Additional notes

Both regular and arrow function IIFEs are affected, both block and line comments are affected and the statement above the comment can be anything at all (like 1 + 1), not just import.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions