Skip to content

Incorrect types for diffJson #609

Closed
@joshkel

Description

@joshkel

@types/diff gave the following types for diffJson:

export function diffJson(
    oldObj: string | object,
    newObj: string | object,
    options?: JsonOptions,
): Change[];
export function diffJson(
    oldObj: string | object,
    newObj: string | object,
    options: Callback<Change[]> | (JsonOptions & CallbackOptions<Change[]>),
): void;

And, since diffJson serializes to JSON itself, these types appear to be correct. However, diff v8 requires string inputs:

export declare function diffJson(oldStr: string, newStr: string, options: DiffCallbackNonabortable<string>): undefined;
export declare function diffJson(oldStr: string, newStr: string, options: DiffJsonOptionsAbortable & CallbackOptionAbortable<string>): undefined;
export declare function diffJson(oldStr: string, newStr: string, options: DiffJsonOptionsNonabortable & CallbackOptionNonabortable<string>): undefined;
export declare function diffJson(oldStr: string, newStr: string, options: DiffJsonOptionsAbortable): ChangeObject<string>[] | undefined;
export declare function diffJson(oldStr: string, newStr: string, options?: DiffJsonOptionsNonabortable): ChangeObject<string>[];

Metadata

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