I have a Node.js project that is built with TypeScript I'm trying to use URLSearchParams, however I can see the following error:

Cannot find name 'URLSearchParams'.ts(2304)
const params = new URLSearchParams();
params.append("foo", 5);

typescript: ^3.9.7
node.js: v12.16.3

While URLSearchParams has lived on the global object in node since v10.0.0, it can be hard to pull ambient type information from there.

The URLSearchParams class lives in the url module, so you can also import it directly from there:

import { URLSearchParams } from "url"

then use it like this:

let queryString = new URLSearchParams({page: "1", pagesize: "100"}).toString();

Also, make sure you install types for node

npm install @types/node --save-dev

Further Reading