jherr / no-bs-ts Goto Github PK
View Code? Open in Web Editor NEWNo BS TS (Typescript) example code
No BS TS (Typescript) example code
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
no-bs-ts/series-1/episode-11/enums.ts
Line 30 in 9bd14de
Now getting a "Duplicate function implementation" error in TS 4.9+
It seems that the setValue
in line-32 is redundant. Since the useEffect is adding a subscriber.
Many thanks for the great content on YouTube!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.