Skip to content

Incorrect TS formatting when used with markup_fmt #775

@ArkenStorm

Description

@ArkenStorm

There's an issue when formatting vue code in combination with the markup_fmt plugin.
Here is the situation:
<SomeTag v-for="[a, b] of arr" />

The first oddity: formatting the file via the CLI (utilizing DPrint) always results in <SomeTag v-for="(a, b) of arr" />, where the square brackets have incorrectly been replaced with parentheses.

The second oddity is that in VS Code (and seemingly Jetbrains Rider as well), when formatting on save or the builtin "Format Document with..." and selecting DPrint FIRST results in this: <SomeTag v-for="([a, b]) of arr" />, which is fine. However, formatting again at that point will result in the square brackets being replaced with parens again, i.e. <SomeTag v-for="(a, b) of arr" />.

The only syntax that keeps things correct is the following: <SomeTag v-for="([a, b], _) of arr" />
That stays consistent across formats.

Running dprint fmt on the file directly goes from <SomeTag v-for="[a, b] of arr" /> to <SomeTag v-for="(a, b) of arr" />. This is not a problem with the markup_fmt plugin, as having it alone formats it correctly. It is only when used in conjunction with the typescript plugin that issues arise.

See this now-closed issue on the markup_fmt plugin

dprint-plugin-typescript version: 0.95.13-0.95.15

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