Open
Description
Checklist
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
I'm building a node backend with TypeScript and I cannot compile the project after installing node-auth0
because it cannot find declarations for RequestInfo
and RequestCredentials
within node-auth0/src/lib/models.ts
.
I was able to work around this by creating a type declaration file in my project like so
import * as undici_types from "undici-types";
declare global {
type RequestInfo = undici_types.RequestInfo;
type RequestCredentials = undici_types.RequestCredentials;
}
I'm not sure if the issue is with undici-types
or with auth0
but I was breaking too much other stuff when I tried to fix this within auth0
.
Reproduction
- Create a new node project with the following:
tsconfig.json
{
"compilerOptions": {
"lib": ["es2022"],
"target": "es2022",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "build",
"rootDir": ".",
"baseUrl": ".",
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"allowJs": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true
},
"include": ["src"]
}
package.json
{
"name": "testing",
"version": "0.0.1",
"main": "build/index.js",
"description": "testing",
"devDependencies": {
"@types/node": "^22.2.0",
"@types/node-fetch": "^2.6.12",
"typescript": "^4.9.5"
},
"dependencies": {
"auth0": "^4.18.0"
},
"scripts": {
"build": "rm -rf ./build/ && tsc"
}
}
src/index.ts
import { ManagementClient as Auth0ManagementClient } from "auth0";
const auth0Client = new Auth0ManagementClient({
domain: "",
clientId: "",
clientSecret: "",
});
export default auth0Client;
- Run
npm install && npm run build
Errors
node_modules/auth0/dist/cjs/lib/models.d.ts:6:36 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
6 export type FetchAPI = (url: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
~~~~~~~~~~~
node_modules/auth0/dist/cjs/lib/models.d.ts:60:19 - error TS2304: Cannot find name 'RequestCredentials'.
60 credentials?: RequestCredentials;
~~~~~~~~~~~~~~~~~~
node_modules/auth0/dist/cjs/lib/models.d.ts:99:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
99 url: URL | RequestInfo;
~~~~~~~~~~~
node_modules/auth0/dist/cjs/lib/models.d.ts:104:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
104 url: URL | RequestInfo;
~~~~~~~~~~~
node_modules/auth0/dist/cjs/lib/models.d.ts:109:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
109 url: URL | RequestInfo;
~~~~~~~~~~~
node_modules/auth0/dist/cjs/lib/models.d.ts:115:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
115 url: URL | RequestInfo;
~~~~~~~~~~~
Found 6 errors in the same file, starting at: node_modules/auth0/dist/cjs/lib/models.d.ts:6
Additional context
No response
node-auth0 version
4.18.0
Node.js version
22.2.0