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

🐛 Formatter inserts syntax errors in TypeScript import() types since 1.9.4 #4421

Closed
1 task done
simon-paris opened this issue Oct 29, 2024 · 2 comments
Closed
1 task done
Labels
S-Needs triage Status: this issue needs to be triaged

Comments

@simon-paris
Copy link
Contributor

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v22.8.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/1.22.22"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    true
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

The JS import statement (JsImportCallExpression) allows a trailing comma after the import path, the typescript import statement (TsImportType) does not.

Since 1.9.4, the formatter will insert trailing commas after long import paths, causing syntax errors.

It was likely introduced here: #3462.

Playground link: https://biomejs.dev/playground/?code=LwAvACAAbwBrACAALQAgAHQAcgBhAGkAbABpAG4AZwAgAGMAbwBtAG0AYQAgAGkAcwAgAGEAbABsAG8AdwBlAGQAIABoAGUAcgBlAAoAYwBvAG4AcwB0ACAAYQAgAD0AIABpAG0AcABvAHIAdAAoACIALgAvAHAAYQB0AGgAIgAsACkALgBkAGUAZgBhAHUAbAB0AAoACgAvAC8AIABpAG4AYwBvAHIAcgBlAGMAdAAgAC0AIAB0AHIAYQBpAGwAaQBuAGcAIABjAG8AbQBtAGEAIABoAGUAcgBlACAAcwBoAG8AdQBsAGQAIABiAGUAIABhACAAcwB5AG4AdABhAHgAIABlAHIAcgBvAHIACgB0AHkAcABlACAAYgAgAD0AIAB0AHkAcABlAG8AZgAgAGkAbQBwAG8AcgB0ACgAIgAuAC8AcABhAHQAaAAiACwAKQAuAGQAZQBmAGEAdQBsAHQACgAKAC8ALwAgAGkAbgBjAG8AcgByAGUAYwB0ACAALQAgAGYAbwByAG0AYQB0AHQAZQByACAAaQBuAHMAZQByAHQAcwAgAGEAIABzAHkAbgB0AGEAeAAgAGUAcgByAG8AcgAKAHQAeQBwAGUAIABjACAAPQAgAHQAeQBwAGUAbwBmACAAaQBtAHAAbwByAHQAKAAiAC4ALwBsAG8AbgBnAC8AbABvAG4AZwAvAGwAbwBuAGcALwBsAG8AbgBnAC8AbABvAG4AZwAvAGwAbwBuAGcALwBsAG8AbgBnAC8AbABvAG4AZwAvAHAAYQB0AGgALwBsAG8AbgBnAC8AbABvAG4AZwAvAGwAbwBuAGcALwBsAG8AbgBnAC8AcABhAHQAaAAiACkALgBkAGUAZgBhAHUAbAB0AAoA

Expected result

Parsing the arguments as JsCallArgumentList is correct for JsImportCallExpression, but not for TsImportType. Typescript parses it completely differently, even though it looks the same.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@simon-paris simon-paris added the S-Needs triage Status: this issue needs to be triaged label Oct 29, 2024
@simon-paris
Copy link
Contributor Author

Ooops, I see this is a duplicate of #4334

@fireairforce
Copy link
Contributor

fireairforce commented Oct 31, 2024

get it, i will update the ungram here, thanks for your feedback, it's very useful for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Needs triage Status: this issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants