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'; ``` 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] 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",