diff --git a/content/blog/22-typescript-flavors.md b/content/blog/22-typescript-flavors.md index e691556..3c6c1eb 100644 --- a/content/blog/22-typescript-flavors.md +++ b/content/blog/22-typescript-flavors.md @@ -41,7 +41,7 @@ this won't work correctly! It'll do something like this: > on the 11th day of christmas... > on the 111th day of christmas... -that's because I've mistakenly defined `n` as `'1'`, in quotes, which means it's actually a string, and not a number. when you do math on things that aren't strings, _sometimes_ it works how you expect, but not _always_. it would be nice if I had a way to scan my source code and say "whoops, did I ever treat the same thing as a string and a number without meaning to do that?" enter TypeScript: +that's because I've mistakenly defined `n` as `'1'`, in quotes, which means it's actually a string, and not a number. when you do math on things that aren't numbers, _sometimes_ it works how you expect, but not _always_. it would be nice if I had a way to scan my source code and say "whoops, did I ever treat the same thing as a string and a number without meaning to do that?" enter TypeScript: ```ts let n = '1'; @@ -54,7 +54,7 @@ TypeScript sees that I messed up, and it says "hey, that's not something you wou you can also tell typescript intentionally 'hey, I am expecting this to be a type' and it'll throw the error even earlier: ```ts -let n: number = 1; +let n: number = '1'; // Type 'string' is not assignable to type 'number'. ```