Skip to content

cb type should expect error as Error | undefined #25

@blumamir

Description

@blumamir

Current type for load function's cb is:

export type INodeStyleCallBack<SuccessArg> = (err: Error, result?: SuccessArg) => void;

But the err can also be null to indicate that the callback has no errors. If trying to invoke the callback with null or undefined, typescript complains with:

Argument of type 'null' is not assignable to parameter of type 'Error'.ts(2345)

I think the type should be

export type INodeStyleCallBack<SuccessArg> = (err: Error | null, result?: SuccessArg) => void;

See for example in node types package:

    export function open(path: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;

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