From 0320846c0c718768ed12be7a5fd0c5e6b1c5f1ed Mon Sep 17 00:00:00 2001 From: Shafkathullah Ihsan Date: Tue, 9 Nov 2021 04:06:40 +0530 Subject: Updates enum docs (#4266) --- typescript.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'typescript.html.markdown') diff --git a/typescript.html.markdown b/typescript.html.markdown index f7a41ce1..64be9401 100644 --- a/typescript.html.markdown +++ b/typescript.html.markdown @@ -48,6 +48,7 @@ let list: Array = [1, 2, 3]; // For enumerations: enum Color { Red, Green, Blue }; let c: Color = Color.Green; +console.log(Color[c]); // "Green" // Lastly, "void" is used in the special case of a function returning nothing function bigHorribleAlert(): void { -- cgit v1.2.3 From ab710a881edf161eb96036f8b0b523057f39a290 Mon Sep 17 00:00:00 2001 From: Edaz Date: Wed, 10 Nov 2021 12:08:47 +1300 Subject: [typescript/en] Add template literal types (#4265) * Add template literal types * Update typescript.html.markdown Co-authored-by: Andre Polykanine Co-authored-by: Andre Polykanine --- typescript.html.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'typescript.html.markdown') diff --git a/typescript.html.markdown b/typescript.html.markdown index 64be9401..74cd15c6 100644 --- a/typescript.html.markdown +++ b/typescript.html.markdown @@ -238,6 +238,16 @@ if (state.type === "success") { console.error(state.message); } +// Template Literal Types +// Use to create complex string types +type OrderSize = "regular" | "large"; +type OrderItem = "Espresso" | "Cappuccino"; +type Order = `A ${OrderSize} ${OrderItem}`; + +let order1: Order = "A regular Cappuccino"; +let order2: Order = "A large Espresso"; +let order3: Order = "A small Espresso"; // Error + // Iterators and Generators // for..of statement -- cgit v1.2.3 From 0e3cf290b248a89dab6f2a7ed0eadbb057e06a39 Mon Sep 17 00:00:00 2001 From: Valentin Baca Date: Sat, 16 Jul 2022 20:05:01 -0700 Subject: Update typescript "Further Reading" links Updated the link to the typescript spec. Removed dead link to "Anders Hejlsberg - Introducing TypeScript on Channel 9" (I couldn't find a replacement. If there is one, please let me know!) Finally, "Definitely Typed - repository for type definitions" just points to a dead page. --- typescript.html.markdown | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'typescript.html.markdown') diff --git a/typescript.html.markdown b/typescript.html.markdown index 74cd15c6..3fe707a0 100644 --- a/typescript.html.markdown +++ b/typescript.html.markdown @@ -291,7 +291,5 @@ foo.baz = 'hello world' ## Further Reading * [TypeScript Official website] (http://www.typescriptlang.org/) - * [TypeScript language specifications] (https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) - * [Anders Hejlsberg - Introducing TypeScript on Channel 9] (http://channel9.msdn.com/posts/Anders-Hejlsberg-Introducing-TypeScript) + * [TypeScript language specifications] (https://github.com/microsoft/TypeScript/blob/main/doc/spec-ARCHIVED.md) * [Source Code on GitHub] (https://github.com/Microsoft/TypeScript) - * [Definitely Typed - repository for type definitions] (http://definitelytyped.org/) -- cgit v1.2.3 From d0c51cbdeb177c85f2ded5d2802456f7dd087f2c Mon Sep 17 00:00:00 2001 From: Kiwimoe Date: Mon, 8 Aug 2022 09:32:53 +0530 Subject: Update TypeScript "Further Reading" links --- typescript.html.markdown | 2 ++ 1 file changed, 2 insertions(+) (limited to 'typescript.html.markdown') diff --git a/typescript.html.markdown b/typescript.html.markdown index 3fe707a0..64f5ca5b 100644 --- a/typescript.html.markdown +++ b/typescript.html.markdown @@ -2,6 +2,7 @@ language: TypeScript contributors: - ["Philippe Vlérick", "https://github.com/pvlerick"] + - ["Kiwimoe", "https://github.com/kiwimoe"] filename: learntypescript.ts --- @@ -292,4 +293,5 @@ foo.baz = 'hello world' ## Further Reading * [TypeScript Official website] (http://www.typescriptlang.org/) * [TypeScript language specifications] (https://github.com/microsoft/TypeScript/blob/main/doc/spec-ARCHIVED.md) + * [Learn TypeScript] (https://learntypescript.dev/) * [Source Code on GitHub] (https://github.com/Microsoft/TypeScript) -- cgit v1.2.3