auth0 / node-auth0

Node.js client library for the Auth0 platform.
MIT License
622 stars 303 forks source link

Error when trying to compile TypeScript project: Cannot find module 'undici' or its corresponding type declarations. #1007

Closed marcusmonteirodesouza closed 1 month ago

marcusmonteirodesouza commented 2 months ago

Checklist

Description

I'm getting the following errors when trying to compile a TypeScript project that has auth0 as a dependency:

node_modules/auth0/dist/cjs/lib/models.d.ts:2:28 - error TS2307: Cannot find module 'undici' or its corresponding type declarations.

import { Dispatcher } from 'undici';


node_modules/auth0/dist/cjs/lib/models.d.ts:6:36 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?

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'.

credentials?: RequestCredentials;


node_modules/auth0/dist/cjs/lib/models.d.ts:99:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?

url: URL | RequestInfo;

node_modules/auth0/dist/cjs/lib/models.d.ts:104:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?

url: URL | RequestInfo;


node_modules/auth0/dist/cjs/lib/models.d.ts:109:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?

url: URL | RequestInfo;

node_modules/auth0/dist/cjs/lib/models.d.ts:115:16 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?

url: URL | RequestInfo;



Found 7 errors in the same file, starting at: node_modules/auth0/dist/cjs/lib/models.d.ts:2

### Reproduction

1. Create a TypeScript project using [gts](https://github.com/google/gts).
2. Run `npm install auth0`.
3. Add the following line to the `index.ts` file: `import * as auth0 from 'auth0';`
4. Run `npm run compile` or, alternatively, `tsc`.

### Additional context

Using [gts](https://github.com/google/gts) to create a TypeScript project.

`package.json`

{
  "name": "",
  "version": "0.0.0",
  "description": "",
  "main": "build/src/index.js",
  "types": "build/src/index.d.ts",
  "files": [
    "build/src"
  ],
  "license": "Apache-2.0",
  "keywords": [],
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "lint": "gts lint",
    "clean": "gts clean",
    "compile": "tsc",
    "fix": "gts fix",
    "prepare": "npm run compile",
    "pretest": "npm run compile",
    "posttest": "npm run lint"
  },
  "devDependencies": {
    "@types/node": "20.11.5",
    "gts": "^5.3.0",
    "typescript": "~5.4.3"
  },
  "dependencies": {
    "auth0": "^4.4.0"
  }
}

`tsconfig.json`

{
  "extends": "./node_modules/gts/tsconfig-google.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "build"
  },
  "include": [
    "src/**/*.ts",
    "test/**/*.ts"
  ]
}

### node-auth0 version

^4.4.0

### Node.js version

20.12.2
danny-hunt commented 2 months ago

Experiencing this too (just the undici error)

node_modules/auth0/dist/cjs/lib/models.d.ts:2:28 - error TS2307: Cannot find module 'undici' or its corresponding type declarations.

sdotson commented 1 month ago

same

gyaneshgouraw-okta commented 1 month ago

Hey @marcusmonteirodesouza thanks for raising this, we’ll take a look.

gyaneshgouraw-okta commented 1 month ago

Fix for this issue is released in https://www.npmjs.com/package/auth0/v/4.4.1