Skip to content

Allow line break before import attributes with keyword #62590

@fisker

Description

@fisker

🔎 Search Terms

"import attributes" "line break" "parse"

🕗 Version & Regression Information

  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAQwLACgCQAzKERwEQYQR6poDuwMAFnAN4wCeYApgFz4BWAzhAHZ4BfIA

💻 Code

import a
	from "foo"
	with {type: "json"}

I believe this is allowed by the spec.

🙁 Actual behavior

TypeScript fails to parse.

🙂 Expected behavior

No error.

Additional information about the issue

I'm from the Prettier team, we are trying to improve the format of import declarations with multiple attributes.
I was thinking that we can break long declarations before the from or with keyword. (Not decided yet)

But since it can't be parsed, so we don't have this option at all.

Ref

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions