Skip to content

Commit c52bd31

Browse files
committed
chore: completes intro
1 parent 71bb84b commit c52bd31

File tree

8 files changed

+117
-9
lines changed

8 files changed

+117
-9
lines changed

examples/hello-ts/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@
1919
"build": "tsc src/index.ts --outDir lib --types node --module commonjs --target ES2017",
2020
"test": "echo 'No tests'"
2121
},
22-
"devDependencies": {}
22+
"devDependencies": {},
23+
"dependencies": {
24+
"eslint": "^6.7.1",
25+
"global": "^4.4.0"
26+
}
2327
}

examples/hello-ts/src/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
/**
4+
* Create a promise that resolves after some time
5+
* @param n number of milliseconds before promise resolves
6+
*/
7+
function timeout(n) {
8+
return new Promise(res => setTimeout(res, n));
9+
}
10+
/**
11+
* Add two numbers
12+
* @param a first number
13+
* @param b second number
14+
*/
15+
async function addNumbers(a, b) {
16+
await timeout(500);
17+
return a + b;
18+
}
19+
exports.addNumbers = addNumbers;
20+
//== Run the program ==//
21+
(async () => {
22+
console.log(await addNumbers(3, 4));
23+
})();

examples/hello-ts/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ function timeout(n: number) {
77
}
88

99
/**
10-
* Add three numbers
10+
* Add two numbers
1111
* @param a first number
12-
* @param b second
12+
* @param b second number
1313
*/
1414
export async function addNumbers(a: number, b: number) {
1515
await timeout(500);

examples/hello-ts/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"include": ["src"],
3+
"compilerOptions": {
4+
"target": "esnext",
5+
"module": "commonjs",
6+
"outDir": "lib"
7+
}
8+
}

notes/1-basics.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
/**
44
* (1) x is a string, b/c we’ve initialized it
55
*/
6-
// let x = "hello world";
6+
let x = "hello world";
77

88
/**
99
* (2) reassignment is fine
1010
*/
11-
// x = "hello mars";
11+
x = "hello mars";
1212

1313
/**
1414
* (3) but if we try to change type
1515
*/
16-
// x = 42; // 🚨 ERROR
16+
x = "42"; // 🚨 ERROR
1717

1818
/**
1919
* (4) let's look at const. The type is literally 'hello world'
2020
*/
21-
// const y = "hello world";
21+
const y = 42;
2222

2323
/**
2424
* This is called a 'string literal type'. y can never be reassigned since it's a const,

ts.code-workspace

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
"code-runner.executorMap": {
6969
"javascript": "node",
7070
"typescript": "node_modules/.bin/ts-node"
71+
},
72+
"workbench.colorCustomizations": {
73+
"activityBar.background": "#4F1F08",
74+
"titleBar.activeBackground": "#6E2C0B",
75+
"titleBar.activeForeground": "#FEF9F7"
7176
}
7277
},
7378
"extensions": {

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"strictFunctionTypes": true,
77
"strictBindCallApply": true,
88
"noUnusedLocals": false,
9-
"noUnusedParameters": false
9+
"noUnusedParameters": false,
1010
},
1111
"include": ["examples/*/src", "challenges/*/src", "notes"]
12-
}
12+
}

yarn.lock

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,11 @@ doctrine@^3.0.0:
26402640
dependencies:
26412641
esutils "^2.0.2"
26422642

2643+
dom-walk@^0.1.0:
2644+
version "0.1.1"
2645+
resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018"
2646+
integrity sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=
2647+
26432648
dot-prop@^3.0.0:
26442649
version "3.0.0"
26452650
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177"
@@ -2897,6 +2902,49 @@ eslint@6.7.0:
28972902
text-table "^0.2.0"
28982903
v8-compile-cache "^2.0.3"
28992904

2905+
eslint@^6.7.1:
2906+
version "6.7.1"
2907+
resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.7.1.tgz#269ccccec3ef60ab32358a44d147ac209154b919"
2908+
integrity sha512-UWzBS79pNcsDSxgxbdjkmzn/B6BhsXMfUaOHnNwyE8nD+Q6pyT96ow2MccVayUTV4yMid4qLhMiQaywctRkBLA==
2909+
dependencies:
2910+
"@babel/code-frame" "^7.0.0"
2911+
ajv "^6.10.0"
2912+
chalk "^2.1.0"
2913+
cross-spawn "^6.0.5"
2914+
debug "^4.0.1"
2915+
doctrine "^3.0.0"
2916+
eslint-scope "^5.0.0"
2917+
eslint-utils "^1.4.3"
2918+
eslint-visitor-keys "^1.1.0"
2919+
espree "^6.1.2"
2920+
esquery "^1.0.1"
2921+
esutils "^2.0.2"
2922+
file-entry-cache "^5.0.1"
2923+
functional-red-black-tree "^1.0.1"
2924+
glob-parent "^5.0.0"
2925+
globals "^12.1.0"
2926+
ignore "^4.0.6"
2927+
import-fresh "^3.0.0"
2928+
imurmurhash "^0.1.4"
2929+
inquirer "^7.0.0"
2930+
is-glob "^4.0.0"
2931+
js-yaml "^3.13.1"
2932+
json-stable-stringify-without-jsonify "^1.0.1"
2933+
levn "^0.3.0"
2934+
lodash "^4.17.14"
2935+
minimatch "^3.0.4"
2936+
mkdirp "^0.5.1"
2937+
natural-compare "^1.4.0"
2938+
optionator "^0.8.3"
2939+
progress "^2.0.0"
2940+
regexpp "^2.0.1"
2941+
semver "^6.1.2"
2942+
strip-ansi "^5.2.0"
2943+
strip-json-comments "^3.0.1"
2944+
table "^5.2.3"
2945+
text-table "^0.2.0"
2946+
v8-compile-cache "^2.0.3"
2947+
29002948
espree@^6.1.2:
29012949
version "6.1.2"
29022950
resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d"
@@ -3560,6 +3608,14 @@ global-dirs@^0.1.0, global-dirs@^0.1.1:
35603608
dependencies:
35613609
ini "^1.3.4"
35623610

3611+
global@^4.4.0:
3612+
version "4.4.0"
3613+
resolved "https://registry.yarnpkg.com/global/-/global-4.4.0.tgz#3e7b105179006a323ed71aafca3e9c57a5cc6406"
3614+
integrity sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==
3615+
dependencies:
3616+
min-document "^2.19.0"
3617+
process "^0.11.10"
3618+
35633619
globals@^12.1.0:
35643620
version "12.3.0"
35653621
resolved "https://registry.yarnpkg.com/globals/-/globals-12.3.0.tgz#1e564ee5c4dded2ab098b0f88f24702a3c56be13"
@@ -5088,6 +5144,13 @@ mimic-fn@^2.0.0, mimic-fn@^2.1.0:
50885144
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
50895145
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
50905146

5147+
min-document@^2.19.0:
5148+
version "2.19.0"
5149+
resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685"
5150+
integrity sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=
5151+
dependencies:
5152+
dom-walk "^0.1.0"
5153+
50915154
minimatch@3.0.4, minimatch@^3.0.4:
50925155
version "3.0.4"
50935156
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
@@ -6212,6 +6275,11 @@ process-nextick-args@~2.0.0:
62126275
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
62136276
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
62146277

6278+
process@^0.11.10:
6279+
version "0.11.10"
6280+
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
6281+
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
6282+
62156283
progress@^2.0.0:
62166284
version "2.0.3"
62176285
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"

0 commit comments

Comments
 (0)