From a0768a8cd7b05b611bae06b3331d289cea19e340 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Mon, 7 Oct 2019 09:12:40 +0200 Subject: [PATCH] better contructor and naming --- index.html | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index 29f91a3..9551e78 100755 --- a/index.html +++ b/index.html @@ -487,25 +487,21 @@

Advanced Stuff


-						type RequireSome<T, K extends keyof T> = {
-							[X in Exclude<keyof T, K>]?: T[X]
-						} & {
-							[P in K]-?: T[P]
-						}
+						import { NonFunctionKeys } from 'utility-types'
 
 						class Auto {
 							wheels!: number
 							doors?: number
 							// ...
 						
-							constructor(init: RequireSome<Auto, 'wheels'>) {
+							constructor(init: Pick<Auto, NonFunctionKeys<Auto>>) {
 								Object.assign(this, init)
 							}
 						}
 
 						const a = new Auto({
-							wheels: 4,
-							doors: 5,
+							wheels: 4, // Required
+							doors: 5,  // Optional
 						})
 					
@@ -561,7 +557,7 @@
-

Options exclude each other

+

Discriminated unions


 						type ColumnProps = {
 							width: number;
@@ -787,22 +783,22 @@
 			fragmentInURL: true,
 			slideNumber: 'c/t',
 			dependencies: [{
-				src: 'https://unpkg.com/reveal.js/plugin/markdown/marked.js'
-			},
-			{
-				src: 'https://unpkg.com/reveal.js/plugin/markdown/markdown.js'
-			},
-			{
-				src: 'https://unpkg.com/reveal.js/plugin/notes/notes.js',
-				async: true
-			},
-			{
-				src: 'https://unpkg.com/reveal.js/plugin/highlight/highlight.js',
-				async: true
-			}
+					src: 'https://unpkg.com/reveal.js/plugin/markdown/marked.js'
+				},
+				{
+					src: 'https://unpkg.com/reveal.js/plugin/markdown/markdown.js'
+				},
+				{
+					src: 'https://unpkg.com/reveal.js/plugin/notes/notes.js',
+					async: true
+				},
+				{
+					src: 'https://unpkg.com/reveal.js/plugin/highlight/highlight.js',
+					async: true
+				}
 			]
 		});
 	
 
 
-
+
\ No newline at end of file