You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have installed node-fetch dependency. However, the conditionals.ts has an error
Argument of type 'unknown' is not assignable to parameter of type 'PokemonResults'.ts(2345)
The data.json response from the fetch function returns Promise<unknown> type
Fix is to cast data to `Promise
fetch(url)
.then((data) => data.json() as Promise<PokemonResults>)
.then((data) => cb(data));
There is also error with fetch.
ts conditionals.ts
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/node_modules/node-fetch/src/index.js from /Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/conditionals.ts not supported.
Instead change the require of index.js in /Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/conditionals.ts to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/conditionals.ts:15:38)
at Module.m._compile (/Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/node_modules/ts-node/dist/index.js:735:29)
at Object.require.extensions.<computed> [as .ts] (/Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/node_modules/ts-node/dist/index.js:737:16)
at main (/Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/node_modules/ts-node/dist/bin.js:238:16)
at Object.<anonymous> (/Users/tonis/workspace/web/ti-no-bs-ts/ts-basics/node_modules/ts-node/dist/bin.js:351:5) {
code: 'ERR_REQUIRE_ESM'
}
The solution is to downgrade fetch to v2. link. yarn add node-fetch adds v3 automatically
The text was updated successfully, but these errors were encountered:
I have installed node-fetch dependency. However, the conditionals.ts has an error
The data.json response from the fetch function returns
Promise<unknown>
typeFix is to cast data to `Promise
There is also error with fetch.
The solution is to downgrade fetch to v2. link.
yarn add node-fetch
adds v3 automaticallyThe text was updated successfully, but these errors were encountered: