From 6419048cb094261209b341da6ba80264734e8e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Wed, 3 Jul 2024 23:35:14 +0900 Subject: [PATCH 1/3] Modified examples with 'typeof' operator. --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5160bfc..0a51dcc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -6,7 +6,7 @@ * KEY_B: 'valueB', * } as const; * - * type ObjectKey = 'KEY_A'|'KEY_B'; + * type ObjectKey = 'KEY_A'|'KEY_B'; */ declare type ObjectKey = keyof T @@ -19,7 +19,7 @@ declare type ObjectKey = keyof T * KEY_B: 'valueB', * } as const; * - * type ObjectValue = 'valueA'|'valueB'; + * type ObjectValue = 'valueA'|'valueB'; */ declare type ObjectValue = T[ObjectKey] From 9a58fd8886c2efe6cb52cb33c26a8816b4ec4dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Wed, 3 Jul 2024 23:35:28 +0900 Subject: [PATCH 2/3] Updated a version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 952e6cb..5f5156e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oshx/type-helper", - "version": "1.0.4", + "version": "1.0.5", "description": "Types help TypeScript types.", "repository": { "type": "git", From caf18be7eeb54cb7fc8f0bdcbce58fab02b1eeba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Wed, 3 Jul 2024 23:35:56 +0900 Subject: [PATCH 3/3] Split the code blocks in README.md. --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 613f246..47f9c9a 100644 --- a/README.md +++ b/README.md @@ -23,16 +23,22 @@ Please add below in `tsconfig.json` file. ```typescript type ObjectKey - // explicit constant object keys + // explicit constant object keys +``` +```typescript type ObjectValue - // explicit constant object values + // explicit constant object values +``` +```typescript type PropsWithClassName - // extendable interface-like-type with optional property 'className' + // extendable interface-like-type with optional property 'className' +``` +```typescript type AnyFunction - // simply declared any function + // simply declared any function ``` ## Why it comes for? @@ -78,6 +84,7 @@ export const ObjectA = { KEY_A: 'valueA', KEY_B: 'valueB', } as const; +// Same effects with Enum type! export type ObjectAKey = ObjectKey; export type ObjectAValue = ObjectValue; @@ -86,7 +93,7 @@ export type ObjectAValue = ObjectValue; const shouldBeKeyOfA: ObjectAKey = 'KeyA'; const shouldBeValueOfA: ObjectAValue = 'ValueA'; -// Passed! +// Passed ✔️ const keyOfA: ObjectAKey = 'KEY_A'; const valueOfA: ObjectAValue = 'valueA'; ```