Skip to content

Can't pass null as 2nd parameter to stringify() #104

Closed

Description

@johndeighan

Describe the bug

I get this error when passing null as 2nd parameter to stringify():

TS2345 [ERROR]: Argument of type 'null' is not assignable to parameter of type '(string | number)[] | ((this: any, key: string, value: any) => any) | undefined'.
console.log(stringify({a:1, b:2}, null, 3));

I can pass null as 2nd parameter to JSON.stringify()
NOTE: I can, in fact, pass undefined as 2nd parameter to your stringify(), so I have an easy workaround


To Reproduce

console.log(stringify({a:1, b:2}, null, 3));

Platform/Env (please complete the following information):
$ deno --version
deno 2.9.3 (stable, release, x86_64-pc-windows-msvc)
v8 14.9.207.2-rusty
typescript 6.0.3

Using flatted 3.4.2

When I look at your stringify() function in github, it look like it should allow null, but it doesn't

Activity

  1. WebReflection commented on Jul 22, 2026

    @WebReflection
    Owner

    this is a TS error and it has nothing to do with the library, right?

  2. WebReflection commented on Jul 22, 2026

    @WebReflection
    Owner

    fixed ... I suppose, this wasn't a library bug though, rather a TS one, the library works just fine.

  3. added a commit that references this issue on Jul 27, 2026
    50a61a9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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