katiewoolston / typescript-workshop-exercises Goto Github PK
View Code? Open in Web Editor NEWSome exercises for learning the basics of TypeScript
Some exercises for learning the basics of TypeScript
Hi @katiewoolston. I fixed the code but with the following:
const saveData = async (data: string) => {
await new Promise((resolve) => {
setTimeout(() => {
console.log("saved data", data);
resolve();
}, 200);
});
return "success";
};
export const script = (): void => {
saveData("some information");
};
script();
I get the following error msg: PS C:\Users\Admin\Downloads\typescript-workshop-exercises\scripts> npm run asyncFunctions
@ asyncFunctions C:\Users\Admin\Downloads\typescript-workshop-exercises
tsc scripts/9_asyncFunctions.ts && node scripts/9_asyncFunctions.js
scripts/9_asyncFunctions.ts:15:13 - error TS2585: 'Promise' only refers to a type, but
is being used as a value here. Do you need to change your target library? Try changing
the lib
compiler option to es2015 or later.
15 await new Promise((resolve) => {
~~~~~~~
Found 1 error.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ asyncFunctions: tsc scripts/9_asyncFunctions.ts && node scripts/9_asyncFunctions.js
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ asyncFunctions script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache_logs\2021-07-05T17_04_45_943Z-debug.log
PS C:\Users\Admin\Downloads\typescript-workshop-exercises\scripts>
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.