Skip to content

Inconsistent multiline printing of record types and values #7961

@cknitt

Description

@cknitt

Comparing ReScript's behavior to Prettier's, Prettier is consistent for types and values, but ReScript is not.

My proposal is to standardize on Prettier's behavior, also because it seems to follow user intention better. If the user put the first record field on a separate line, we may assume that they intend to keep the formatting multiline and/or add more fields later.

Prettier

Types

type X = { a: number }; type Y = { a: number }; type Z = { a: number };

reformats to

type X = { a: number }; type Y = { a: number }; type Z = { a: number; };

Values

let x = { a: 2 }; let x = { a: 2, }; let x = { a: 2, };

reformats to

let x = { a: 2 }; let x = { a: 2 }; let x = { a: 2, };

ReScript

Types

type x = {a: int} type y = {a: int } type z = { a: int, }

reformats to

type x = {a: int} type y = {a: int} type z = {a: int} 

Values

let x = {a: 2} let x = {a: 2 } let x = { a: 2 }

reformats to

let x = {a: 2} let x = { a: 2, } let x = { a: 2, } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterIssues related to code formatting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions