Skip to content

Commit 977e6dd

Browse files
committed
feat: adding contextual typing and function typing with inference
1 parent dd145b4 commit 977e6dd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lesson2/functions.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const add = (a: number, b: number) => {
2+
return a + b;
3+
};
4+
5+
// No type annotations here, but TypeScript can spot the bug
6+
const names = ["Alice", "Bob", "Eve"];
7+
8+
// Contextual typing for function
9+
names.forEach(function (s) {
10+
console.log(s.toUpperCase());
11+
});

0 commit comments

Comments
 (0)