Skip to content

lib: fix handling of non-object options parameter in fs/watchFile

Problem I resolved

const { watchFile } = require("fs");

// watchFile(filename:string|Buffer|URL, options:object, listener:function)
watchFile("./note.txt", "string", (curr, prev) => {});

It causes TypeError:

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received type string ('string')
    at watchFile (node:fs:2514:3)
   ...
}

I think The "options" argument must be of type object ... is correct error message instead of The "listener" argument must be of type function. Received type string ('string'). so I fixed it

Merge request reports

Loading