NodeJS 18 now has the fetch API built in which includes support for all the normal Request/Response types supported by that API.
Right now if I attempt to use the tsconfig for NodeJS 18:
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"lib": [
"ES2022"
]
}
If I attempt to use the fetch API in code (or any of the classes related to it like Request/Response), I get:
error TS2304: Cannot find name 'fetch'.
If I add dom to the lib element in the compilerOptions, it compiles successfully but then I have access to the entire dom library which I don't want.
Can we get a lib option of Node18 that adds all the classes related to the fetch APIs added in Node18? Or maybe just dom.fetch or something?