Skip to content

attest: add option to normalize property/union order when serializing types #1270

Open
@ssalbdivad

Description

@ssalbdivad

This would allow alphabetizing properties/union members when serializing a type like:

declare const t: {
    b: "b" | "a"
    a: 1
}


attest(t).type.toString.normalizedSnap(`{
    a: 1
    b: "a" | "b"
}`)

Can be useful for property order that can change across versions

Have considered patching tsc (although it seems hard to access emitObjectLiteralExpression externally since it is defined in the createPrinter function). Also could potentially join displayParts, but some complexity there as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    external-contributor-friendlyDoesn't rely heavily on contextual knowledge of ArkType (may still be complex)

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions