From cf4da1edaa8ecaad0099d8ff4a015ffcbce9b6f3 Mon Sep 17 00:00:00 2001 From: Nanda Date: Mon, 29 Apr 2024 15:00:18 +1000 Subject: [PATCH 1/2] Simplify type of Text component. Save 16 seconds from typescript compile step. --- lib/Styled/Styled.types.ts | 6 ------ lib/Styled/Text.tsx | 7 +++---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/Styled/Styled.types.ts b/lib/Styled/Styled.types.ts index 26b30bdd665..2d83724fc05 100644 --- a/lib/Styled/Styled.types.ts +++ b/lib/Styled/Styled.types.ts @@ -23,12 +23,6 @@ export type WhiteSpace = | "initial" | "inherit"; -export type OneKeyFrom = K extends any - ? Pick & Partial, never>> extends infer O - ? { [P in keyof O]: O[P] } - : never - : never; - /** * Types that can be used after upgrade to ts4. */ diff --git a/lib/Styled/Text.tsx b/lib/Styled/Text.tsx index 0e58759baab..73819e0ad4d 100644 --- a/lib/Styled/Text.tsx +++ b/lib/Styled/Text.tsx @@ -1,6 +1,5 @@ import { ComponentProps } from "react"; import styled from "styled-components"; -import { OneKeyFrom } from "./Styled.types"; interface ITextSize { noFontSize?: boolean; @@ -52,9 +51,9 @@ export interface ITextPropsBase { } export type ITextProps = ITextPropsBase & - OneKeyFrom & - OneKeyFrom & - OneKeyFrom & + ITextSize & + ITextColor & + ITextWeight & ComponentProps<"div">; // should it be a span or inline-block-div? - leaning to div From 94f5c66749d6c695d0a1b4735c666c5418b138d2 Mon Sep 17 00:00:00 2001 From: Nanda Date: Mon, 29 Apr 2024 15:15:46 +1000 Subject: [PATCH 2/2] Remove OneKeyFrom type for Box. --- lib/Styled/Box.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Styled/Box.tsx b/lib/Styled/Box.tsx index 25ce8be9d4b..0811606137f 100644 --- a/lib/Styled/Box.tsx +++ b/lib/Styled/Box.tsx @@ -1,6 +1,6 @@ import { Ref } from "react"; import styled from "styled-components"; -import { OneKeyFrom, Overflow, WhiteSpace, WordBreak } from "./Styled.types"; +import { Overflow, WhiteSpace, WordBreak } from "./Styled.types"; interface Column { col1?: boolean; @@ -68,7 +68,7 @@ export interface IBoxPropsBase { as?: React.ElementType | keyof JSX.IntrinsicElements; } -export type IBoxProps = IBoxPropsBase & OneKeyFrom; +export type IBoxProps = IBoxPropsBase & Column; export const Box = styled.div` display: flex;