Number of TypeScript type errors
See original GitHub issueReproduction
Steps to reproduce the behavior:
yarn install node-fetch
(3.2.10
)tsc -p tsconfig.json --noEmit
- get the following errors:
$ tsc -p tsconfig.json --noEmit
node_modules/fetch-blob/file.d.ts:1:76 - error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
1 /** @type {typeof globalThis.File} */ export const File: typeof globalThis.File;
~~~~
node_modules/fetch-blob/from.d.ts:20:64 - error TS2749: 'File' refers to a value, but is being used as a type here. Did you mean 'typeof File'?
20 export function fileFrom(path: string, type?: string): Promise<File>;
~~~~
node_modules/fetch-blob/from.d.ts:25:60 - error TS2749: 'File' refers to a value, but is being used as a type here. Did you mean 'typeof File'?
25 export function fileFromSync(path: string, type?: string): File;
~~~~
node_modules/fetch-blob/index.d.ts:2:38 - error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
2 export const Blob: typeof globalThis.Blob;
~~~~
node_modules/formdata-polyfill/esm.min.d.ts:2:11 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
2 new (): FormData;
~~~~~~~~
node_modules/formdata-polyfill/esm.min.d.ts:3:14 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
3 prototype: FormData;
~~~~~~~~
node_modules/formdata-polyfill/esm.min.d.ts:5:50 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
5 export declare function formDataToBlob(formData: FormData): Blob;
~~~~~~~~
node_modules/node-fetch/@types/index.d.ts:124:4 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
124 | FormData
~~~~~~~~
node_modules/node-fetch/@types/index.d.ts:137:22 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
137 formData(): Promise<FormData>;
~~~~~~~~
Found 9 errors in 5 files.
Errors Files
1 node_modules/fetch-blob/file.d.ts:1
2 node_modules/fetch-blob/from.d.ts:20
1 node_modules/fetch-blob/index.d.ts:2
3 node_modules/formdata-polyfill/esm.min.d.ts:2
2 node_modules/node-fetch/@types/index.d.ts:124
error Command failed with exit code 2.
My tsconfig.json
looks like this:
{
"compileOnSave": true,
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "CommonJS",
"noImplicitAny": true,
"noImplicitReturns": true,
"outDir": "dist",
"resolveJsonModule": true,
"rootDir": "src",
"strict": true,
"target": "ES2021",
"typeRoots": ["./src/@types", "./node_modules/@types"]
},
"exclude": ["**/__tests__", "node_modules"],
"include": ["./src/**/*.ts"]
}
Expected behavior
There should be no type errors
Screenshots
Your Environment
software | version |
---|---|
node-fetch | 3.2.10 |
node | 16.16.0 |
yarn | 1.22.19 |
typescript | 4.7.4 |
Operating System | MacOS 12.4 |
Additional context
Issue Analytics
- State:
- Created a year ago
- Reactions:11
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Documentation - Understanding Errors - TypeScript
Understanding Errors. Whenever TypeScript finds an error, it tries to explain what went wrong in as much detail as possible. Because its type...
Read more >TypeScript errors and how to fix them
Common Errors. Below you find a list of common TypeScript errors along with the buggy code and its fixed version. If you're interested...
Read more >Complete list of Typescript error codes and their fixes
I expect you post an answer regarding the new Typescript (currently 1.6 is the most recent).
Read more >Improving TypeScript error handling with exhaustive type ...
Discover an improved method for handling errors in TypeScript that solves problems that arise from returning null and throwing try...catch.
Read more >Type-Safe Error Handling In TypeScript - DEV Community
import { ok, err, Result } from 'neverthrow' // we'll keep this simple type ResponseBody = {} interface ResponseData { statusCode: number ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Adding “DOM” to tsconfig.json also works as a temporary workaround
But
3.2.8
has CVE-2022-2596. @jimmywarting: would you revert the merge of https://github.com/node-fetch/node-fetch/commit/bcfb71c7d10da252280d13818daab6925e12c368?