Skip to content

Instantly share code, notes, and snippets.

@panva

panva/README.md Secret

Last active September 23, 2024 10:04
Show Gist options
  • Save panva/a350238b643aef7a77b29e6db395c3b9 to your computer and use it in GitHub Desktop.
Save panva/a350238b643aef7a77b29e6db395c3b9 to your computer and use it in GitHub Desktop.
git clone https://gist.github.com/panva/a350238b643aef7a77b29e6db395c3b9 response-type-reproduction
cd response-type-reproduction
npm i
npx tsc
index.ts:4:3 - error TS2322: Type 'Promise<import("./node_modules/undici/types/fetch").Response>' is not assignable to type 'Promise<Response>'.
  Type 'import("./node_modules/undici/types/fetch").Response' is not assignable to type 'Response'.
    The types returned by 'headers.entries()' are incompatible between these types.
      Type 'SpecIterableIterator<[string, string]>' is missing the following properties from type 'HeadersIterator<[string, string]>': map, filter, take, drop, and 9 more.

4   return undici.fetch(url)
    ~~~~~~


Found 1 error in index.ts:4
import * as undici from 'undici'
function req(url: string): Promise<Response> {
return undici.fetch(url)
}
await req('https://nodejs.org/')
{
"name": "pg",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "pg",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"undici": "^6.19.8"
},
"devDependencies": {
"@types/node": "^22.5.5",
"typescript": "~5.6.2"
}
},
"node_modules/@types/node": {
"version": "22.5.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz",
"integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~6.19.2"
}
},
"node_modules/typescript": {
"version": "5.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz",
"integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/undici-types": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"dev": true,
"license": "MIT"
}
}
}
{
"name": "pg",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"type": "module",
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/node": "^22.5.5",
"typescript": "~5.6.2"
},
"dependencies": {
"undici": "^6.19.8"
}
}
{
"include": ["**/*.ts"],
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"types": ["node"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment