Skip to content

Delta type is too wide #368

Open
Open
@samhh

Description

Between 0.5 and 0.6 the Delta type returned by diff changed. It used to be:

export interface Delta {
    [key: string]: any;
    [key: number]: any;
}

Now it's:

export type Delta = AddedDelta | ModifiedDelta | DeletedDelta | ObjectDelta | ArrayDelta | MovedDelta | TextDiffDelta | undefined;

Where many of those are typed partially with unknown.

This is undoubtedly an improvement, however I wonder if we could narrow unknown down at all?

My use case is trying to work with JSON safely , for example via fp-ts' Json type: https://github.com/gcanti/fp-ts/blob/2.16.5/src/Json.ts#L10.

export type Json = boolean | number | string | null | JsonArray | JsonRecord

This enables infallible stringification.

I suspect Delta is already implicitly a subtype of Json, however if not it'd be good to know that. Cheers!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions