Skip to content

TypeScript: type assertions (as) aren't wrapped #6443

@thorn0

Description

@thorn0

Prettier 1.18.2
Playground link

--parser typescript

Input:

const bifornCringerMoshedPerplexSawder = 
  askTrovenaBeenaDependsRowans as glimseGlyphsHazardNoopsTieTie;
  
averredBathersBoxroomBuggyNurl.anodyneCondosMalateOverateRetinol = 
  annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave;

averredBathersBoxroomBuggyNurl = {
  anodyneCondosMalateOverateRetinol:
    annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave
};

averredBathersBoxroomBuggyNurl(
  anodyneCondosMalateOverateRetinol.annularCooeedSplicesWalksWayWay as 
    kochabCooieGameOnOboleUnweave
);

Output:

const bifornCringerMoshedPerplexSawder = askTrovenaBeenaDependsRowans as glimseGlyphsHazardNoopsTieTie;

averredBathersBoxroomBuggyNurl.anodyneCondosMalateOverateRetinol = annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave;

averredBathersBoxroomBuggyNurl = {
  anodyneCondosMalateOverateRetinol: annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave
};

averredBathersBoxroomBuggyNurl(
  anodyneCondosMalateOverateRetinol.annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave
);

Expected behavior:
See input.

Note that as, if wrapped, should stay at the end of the line. This is not valid TS:

const bifornCringerMoshedPerplexSawder = askTrovenaBeenaDependsRowans
  as glimseGlyphsHazardNoopsTieTie;

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions