From 0e437a75db091eb5cb057f1a49bf07db562d1d8f Mon Sep 17 00:00:00 2001
From: davidgtu <david.giahuy.tu@gmail.com>
Date: Fri, 11 Oct 2019 15:53:07 -0400
Subject: add type assertion

---
 typescript.html.markdown | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'typescript.html.markdown')

diff --git a/typescript.html.markdown b/typescript.html.markdown
index cf2111d5..6c6da2c4 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -257,8 +257,24 @@ for (const i in list) {
    console.log(i); // 0, 1, 2
 }
 
+// Type Assertion
 
+let foo = {} // Creating foo as an empty object
+foo.bar = 123 // Error: property 'bar' does not exist on `{}`
+foo.baz = 'hello world' // Error: property 'baz' does not exist on `{}`
 
+// Because the inferred type of foo is `{}` (an object with 0 properties), you 
+// are not allowed to add bar and baz to it. However with type assertion,
+// the following will pass:
+
+interface Foo { 
+  bar: number;
+  baz: string;
+}
+
+let foo = {} as Foo; // Type assertion here
+foo.bar = 123;
+foo.baz = 'hello world'
 
 ```
 
-- 
cgit v1.2.3


From fb48be47d6cac609cf9d29caae5d4e73df3e214a Mon Sep 17 00:00:00 2001
From: Ross Mackay <ross@mcky.me>
Date: Tue, 22 Oct 2019 13:16:52 +0100
Subject: Fix outdated comment in en/th-th typescript docs

---
 typescript.html.markdown | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'typescript.html.markdown')

diff --git a/typescript.html.markdown b/typescript.html.markdown
index cf2111d5..6f238d5b 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -199,7 +199,7 @@ interface Person {
 }
 
 var p1: Person = { name: "Tyrone", age: 42 };
-p1.age = 25; // Error, p1.x is read-only
+p1.age = 25; // Error, p1.age is read-only
 
 var p2 = { name: "John", age: 60 };
 var p3: Person = p2; // Ok, read-only alias for p2
-- 
cgit v1.2.3


From 5a7d3e898b11fb09cfa448e924ef09970b071a51 Mon Sep 17 00:00:00 2001
From: Kyle Mendes <kyle@springhealth.com>
Date: Thu, 31 Oct 2019 18:42:00 -0500
Subject: Fix playground link

---
 typescript.html.markdown | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'typescript.html.markdown')

diff --git a/typescript.html.markdown b/typescript.html.markdown
index 6f238d5b..a4f1423f 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -16,7 +16,7 @@ This article will focus only on TypeScript extra syntax, as opposed to
 [JavaScript](/docs/javascript).
 
 To test TypeScript's compiler, head to the
-[Playground] (http://www.typescriptlang.org/Playground) where you will be able
+[Playground](http://www.typescriptlang.org/Playground) where you will be able
 to type code, have auto completion and directly see the emitted JavaScript.
 
 ```ts
-- 
cgit v1.2.3


From d430cd82b6c00d0df4aa637697caaaf490cda191 Mon Sep 17 00:00:00 2001
From: Kyle Mendes <kyle@springhealth.com>
Date: Mon, 4 Nov 2019 14:11:16 -0600
Subject: Updating the TS playground link

---
 typescript.html.markdown | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'typescript.html.markdown')

diff --git a/typescript.html.markdown b/typescript.html.markdown
index a4f1423f..00f0cbc5 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -16,7 +16,7 @@ This article will focus only on TypeScript extra syntax, as opposed to
 [JavaScript](/docs/javascript).
 
 To test TypeScript's compiler, head to the
-[Playground](http://www.typescriptlang.org/Playground) where you will be able
+[Playground](https://www.typescriptlang.org/play) where you will be able
 to type code, have auto completion and directly see the emitted JavaScript.
 
 ```ts
-- 
cgit v1.2.3


From 5a57d01d05d1b53a8e2eb267ecc56ddbd75a6d46 Mon Sep 17 00:00:00 2001
From: lemusthelroy <lewis.john.thorley@gmail.com>
Date: Fri, 13 Dec 2019 07:43:47 +0000
Subject: Update typescript.html.markdown

This will overcome TSError:2362 : "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type"
---
 typescript.html.markdown | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'typescript.html.markdown')

diff --git a/typescript.html.markdown b/typescript.html.markdown
index 00f0cbc5..eeda0b7b 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -139,7 +139,7 @@ class Point3D extends Point {
   // Overwrite
   dist() {
     let d = super.dist();
-    return Math.sqrt(d * d + this.z * this.z);
+    return Math.sqrt(d() * d() + this.z * this.z);
   }
 }
 
-- 
cgit v1.2.3


From d0e82c10cd98e82100f3efac298d24d4d58ded9e Mon Sep 17 00:00:00 2001
From: Rett Berg <rett@google.com>
Date: Sat, 21 Mar 2020 11:20:23 -0600
Subject: add type to Point.dist and fix error

---
 typescript.html.markdown | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'typescript.html.markdown')

diff --git a/typescript.html.markdown b/typescript.html.markdown
index 640be0cd..f7a41ce1 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -114,7 +114,7 @@ class Point {
   }
 
   // Functions
-  dist() { return Math.sqrt(this.x * this.x + this.y * this.y); }
+  dist(): number { return Math.sqrt(this.x * this.x + this.y * this.y); }
 
   // Static members
   static origin = new Point(0, 0);
@@ -137,9 +137,9 @@ class Point3D extends Point {
   }
 
   // Overwrite
-  dist() {
+  dist(): number {
     let d = super.dist();
-    return Math.sqrt(d() * d() + this.z * this.z);
+    return Math.sqrt(d * d + this.z * this.z);
   }
 }
 
-- 
cgit v1.2.3