From 00c9fef0ef58828a3357330bc76e9c6ce7cc9950 Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Sun, 21 May 2023 18:44:54 +0300 Subject: [PATCH 1/8] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=83?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D0=BD=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/easy1.ts | 5 ++++- lessons/module2/1_TypescriptPart2/homework/easy2.ts | 7 ++++++- lessons/module2/1_TypescriptPart2/homework/easy3.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/easy1.ts b/lessons/module2/1_TypescriptPart2/homework/easy1.ts index 938773d6..4173b034 100644 --- a/lessons/module2/1_TypescriptPart2/homework/easy1.ts +++ b/lessons/module2/1_TypescriptPart2/homework/easy1.ts @@ -3,7 +3,10 @@ // Нужно заменить FIXME на тип который вычисляется на освове OrderState // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = any; + +type FilteredStates = "initial" | "inWork" | "fullfilled"; + +type FIXME = Array; const orderStates = [ "initial", diff --git a/lessons/module2/1_TypescriptPart2/homework/easy2.ts b/lessons/module2/1_TypescriptPart2/homework/easy2.ts index ecf004fe..0f503309 100644 --- a/lessons/module2/1_TypescriptPart2/homework/easy2.ts +++ b/lessons/module2/1_TypescriptPart2/homework/easy2.ts @@ -3,7 +3,12 @@ // Нужно заменить FIXME на тип который достанет из Order все возможные состояния (state) // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = any; +type FIXME = + | "initial" + | "inWork" + | "buyingSupplies" + | "producing" + | "fullfilled"; type Order = | { diff --git a/lessons/module2/1_TypescriptPart2/homework/easy3.ts b/lessons/module2/1_TypescriptPart2/homework/easy3.ts index 348b8146..120a4b9e 100644 --- a/lessons/module2/1_TypescriptPart2/homework/easy3.ts +++ b/lessons/module2/1_TypescriptPart2/homework/easy3.ts @@ -3,7 +3,7 @@ // Нужно заменить FIXME на соответствующий тип // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = any; +type FIXME = Record; // eslint-disable-next-line @typescript-eslint/no-explicit-any export const omit = , K extends keyof T>( From c331d08f65f771c3f9f958a3ea8add6e1b0a24d3 Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Tue, 23 May 2023 21:50:31 +0300 Subject: [PATCH 2/8] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20medi?= =?UTF-8?q?um?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/medium1.ts | 3 ++- lessons/module2/1_TypescriptPart2/homework/medium2.ts | 2 +- lessons/module2/1_TypescriptPart2/homework/medium3.ts | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/medium1.ts b/lessons/module2/1_TypescriptPart2/homework/medium1.ts index 15b76fbe..74d63f85 100644 --- a/lessons/module2/1_TypescriptPart2/homework/medium1.ts +++ b/lessons/module2/1_TypescriptPart2/homework/medium1.ts @@ -5,7 +5,8 @@ // Нужно заменить FIXME на правильный тип вычисленный на основе Order // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = any; +type GoodNames = "initial" | "inWork"; +type FIXME = { state: GoodNames; sum: number; workerId?: number } | null; type Order = | { diff --git a/lessons/module2/1_TypescriptPart2/homework/medium2.ts b/lessons/module2/1_TypescriptPart2/homework/medium2.ts index 1ec88f5f..7c0e1de5 100644 --- a/lessons/module2/1_TypescriptPart2/homework/medium2.ts +++ b/lessons/module2/1_TypescriptPart2/homework/medium2.ts @@ -3,7 +3,7 @@ // Нужно заменить FIXME на правильный тип // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = any; +type FIXME = React.ComponentType; // Hint: infer export const getDefaultProps = ( diff --git a/lessons/module2/1_TypescriptPart2/homework/medium3.ts b/lessons/module2/1_TypescriptPart2/homework/medium3.ts index 71b9f1e4..6a8b1183 100644 --- a/lessons/module2/1_TypescriptPart2/homework/medium3.ts +++ b/lessons/module2/1_TypescriptPart2/homework/medium3.ts @@ -1,5 +1,7 @@ +type FilteredStates = Array[number]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = any; +type FIXME = Array; const orderStates = [ "initial", From 35b286a8b48b74e96705dcd5f88a4e1c2fb2a916 Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Sun, 4 Jun 2023 13:22:59 +0300 Subject: [PATCH 3/8] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/easy1.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/easy1.ts b/lessons/module2/1_TypescriptPart2/homework/easy1.ts index 4173b034..5263e960 100644 --- a/lessons/module2/1_TypescriptPart2/homework/easy1.ts +++ b/lessons/module2/1_TypescriptPart2/homework/easy1.ts @@ -4,9 +4,7 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FilteredStates = "initial" | "inWork" | "fullfilled"; - -type FIXME = Array; +type FIXME = Array>; const orderStates = [ "initial", From 401603f478ad1e8c5494d0c9a51bf7f4cdf5c47c Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Sun, 4 Jun 2023 16:31:22 +0300 Subject: [PATCH 4/8] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/easy2.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/easy2.ts b/lessons/module2/1_TypescriptPart2/homework/easy2.ts index 0f503309..47f5fa7b 100644 --- a/lessons/module2/1_TypescriptPart2/homework/easy2.ts +++ b/lessons/module2/1_TypescriptPart2/homework/easy2.ts @@ -3,12 +3,7 @@ // Нужно заменить FIXME на тип который достанет из Order все возможные состояния (state) // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = - | "initial" - | "inWork" - | "buyingSupplies" - | "producing" - | "fullfilled"; +type FIXME = Order["state"]; type Order = | { From cf9232028763e93c232599118bdcdb181fbf8627 Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Sun, 4 Jun 2023 17:21:22 +0300 Subject: [PATCH 5/8] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/easy3.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/easy3.ts b/lessons/module2/1_TypescriptPart2/homework/easy3.ts index 120a4b9e..1705fd75 100644 --- a/lessons/module2/1_TypescriptPart2/homework/easy3.ts +++ b/lessons/module2/1_TypescriptPart2/homework/easy3.ts @@ -3,13 +3,16 @@ // Нужно заменить FIXME на соответствующий тип // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = Record; +type FIXME, K extends keyof T> = Pick< + T, + Exclude +>; // eslint-disable-next-line @typescript-eslint/no-explicit-any export const omit = , K extends keyof T>( obj: T, keyToOmit: K -): FIXME => { +): FIXME => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { [keyToOmit]: _, ...withoutKey } = obj; return withoutKey; From b8d4f80c053f306705bbd6e5375158291e8e61c7 Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Sun, 4 Jun 2023 17:25:00 +0300 Subject: [PATCH 6/8] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201=20mediu?= =?UTF-8?q?m1.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/medium1.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/medium1.ts b/lessons/module2/1_TypescriptPart2/homework/medium1.ts index 74d63f85..d064f77c 100644 --- a/lessons/module2/1_TypescriptPart2/homework/medium1.ts +++ b/lessons/module2/1_TypescriptPart2/homework/medium1.ts @@ -5,8 +5,7 @@ // Нужно заменить FIXME на правильный тип вычисленный на основе Order // eslint-disable-next-line @typescript-eslint/no-explicit-any -type GoodNames = "initial" | "inWork"; -type FIXME = { state: GoodNames; sum: number; workerId?: number } | null; +type FIXME = Extract | null; type Order = | { From 67145156cde6ea5ef6eb4d9c04a2d24ad6c72e96 Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Sun, 4 Jun 2023 17:38:43 +0300 Subject: [PATCH 7/8] =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BD=D0=B0=20infer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/medium2.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/medium2.ts b/lessons/module2/1_TypescriptPart2/homework/medium2.ts index 7c0e1de5..ef919386 100644 --- a/lessons/module2/1_TypescriptPart2/homework/medium2.ts +++ b/lessons/module2/1_TypescriptPart2/homework/medium2.ts @@ -3,11 +3,11 @@ // Нужно заменить FIXME на правильный тип // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = React.ComponentType; +type FIXME = T extends (...args: any[]) => infer U ? U : T; // Hint: infer export const getDefaultProps = ( component: React.ComponentType -): FIXME => { +): FIXME => { return component.defaultProps; }; From 3a2fe438324a6979919aad292d5d3dcafb79991a Mon Sep 17 00:00:00 2001 From: "d.plushchenkov" Date: Sun, 4 Jun 2023 17:44:39 +0300 Subject: [PATCH 8/8] =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BD=D0=B0=20exclude?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lessons/module2/1_TypescriptPart2/homework/medium3.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lessons/module2/1_TypescriptPart2/homework/medium3.ts b/lessons/module2/1_TypescriptPart2/homework/medium3.ts index 6a8b1183..ebeabd47 100644 --- a/lessons/module2/1_TypescriptPart2/homework/medium3.ts +++ b/lessons/module2/1_TypescriptPart2/homework/medium3.ts @@ -1,7 +1,7 @@ -type FilteredStates = Array[number]; - // eslint-disable-next-line @typescript-eslint/no-explicit-any -type FIXME = Array; +type FIXME = Array< + Exclude +>; const orderStates = [ "initial",