mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
step 2-1 demo notes
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
# Step 2.1: Introduction to Typescript
|
# Step 2.1: Introduction to Typescript
|
||||||
|
|
||||||
In this exercise, we'll cover enough of the Typescript concepts to be productive with the React & Redux frameworks.
|
In this step, we'll cover enough of the Typescript concepts to be productive with the React & Redux frameworks.
|
||||||
|
|
||||||
Topics in this Exercise will include:
|
Topics in this step will include:
|
||||||
|
|
||||||
- ES modules
|
- ES modules
|
||||||
- Basic Types
|
- Basic Types
|
||||||
@@ -11,6 +11,8 @@ Topics in this Exercise will include:
|
|||||||
- Spread and Destructuring
|
- Spread and Destructuring
|
||||||
- Async / Await
|
- Async / Await
|
||||||
|
|
||||||
|
Have a look at the `demo/src/` files to get a sense of what those are
|
||||||
|
|
||||||
# Exercise
|
# Exercise
|
||||||
|
|
||||||
Please complete all exercises inside the `exercise/src` folder unless otherwise specified in the exercises below. First, open up [Step2-01 exercise page](http://localhost:8080/step2-01/exercise/) to see the results while you're implementing things.
|
Please complete all exercises inside the `exercise/src` folder unless otherwise specified in the exercises below. First, open up [Step2-01 exercise page](http://localhost:8080/step2-01/exercise/) to see the results while you're implementing things.
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { namedConst, namedFn, namedObj, namedConstBracket, namedConst as c } from './named';
|
// These are named imports from a file relative to this file
|
||||||
|
import { namedConst, namedFn, namedObj, namedConstBracket } from './named';
|
||||||
|
|
||||||
|
// We can even apply an alias to the named constant
|
||||||
|
import { namedConst as c } from './named';
|
||||||
|
|
||||||
|
// These are the same instances of the named imports, but gets imported all at the same time under a single object
|
||||||
import * as named from './named';
|
import * as named from './named';
|
||||||
|
|
||||||
// Print out the exports
|
// Print out the exports
|
||||||
@@ -14,6 +20,9 @@ console.log(named.namedFn());
|
|||||||
console.log(named.namedObj);
|
console.log(named.namedObj);
|
||||||
console.log(named.namedConstBracket);
|
console.log(named.namedConstBracket);
|
||||||
|
|
||||||
|
// Default import can be named anything we want as the consumer
|
||||||
import DefaultClass from './default';
|
import DefaultClass from './default';
|
||||||
|
import Foo from './default';
|
||||||
|
|
||||||
console.log(new DefaultClass().hello);
|
console.log(new DefaultClass().hello);
|
||||||
|
console.log(new Foo().hello);
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ export const namedObj = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const namedConstBracket = 10;
|
const namedConstBracket = 10;
|
||||||
|
|
||||||
export { namedConstBracket };
|
export { namedConstBracket };
|
||||||
|
|||||||
Reference in New Issue
Block a user