Gathering detailed insights and metrics for @kakasoo/deep-strict-types
Gathering detailed insights and metrics for @kakasoo/deep-strict-types
Utility Types to quickly query and Omit, Pick keys inside nested arrays and objects
npm install @kakasoo/deep-strict-types
Typescript
Module System
Node Version
NPM Version
74.5
Supply Chain
98.2
Quality
93.1
Maintenance
100
Vulnerability
99.3
License
TypeScript (100%)
Total Downloads
5,024
Last Day
6
Last Week
175
Last Month
3,728
Last Year
5,024
19 Stars
109 Commits
1 Forks
1 Watching
2 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.25
Package Id
@kakasoo/deep-strict-types@1.0.25
Unpacked Size
49.84 kB
Size
12.68 kB
File Count
79
NPM Version
10.8.2
Node Version
20.18.1
Publised On
20 Jan 2025
Cumulative downloads
Total Downloads
Last day
-88.5%
6
Compared to previous day
Last week
-87.6%
175
Compared to previous week
Last month
234.1%
3,728
Compared to previous month
Last year
0%
5,024
Compared to previous year
1
1npm i @kakasoo/deep-strict-types
DeepStrictTypes extends TypeScript utility types, enabling safe operations like Omit
and Pick
on nested objects or arrays by specifying the keys to be inferred. This allows for more strict and accurate type checks. Now, you don't have to recombine numerous types daily to remove a single key from a nested object. You can quickly omit and pick the internal keys you want!
DeepStrictObjectKeys<T>
extracts all nested keys from an object T
, preserving the structure of the nested object and returning the types of the keys. This is useful when you need to handle specific keys safely at deeper levels of an object.
1type Example = { 2 user: { 3 name: string; 4 address: { 5 city: string; 6 zip: number; 7 }; 8 }; 9}; 10 11// Result: "user" | "user.name" | "user.address" | "user.address.city" | "user.address.zip" 12type Keys = DeepStrictObjectKeys<Example>;
In the case of an array, the inside is represented by the [*]
symbol. Of course, the arrangement of the array, the arrangement of objects in the array, and even if the top object is an array, it is perfectly inferred.
DeepStrictOmit<T, K>
creates a new type by excluding properties corresponding to the key K from object T, while preserving the nested structure. This type allows precise omission of keys even in deeply nested objects.
1type Example = { 2 user: { 3 name: string; 4 age: number; 5 }; 6}; 7 8// Result: { user: { age: number; } } 9type Omitted = DeepStrictOmit<Example, 'user.name'>;
This is also useful for branding types. Below is an example of defining a branding type using a library called typia, in which DeepStrictOmit can also be safely used.
1test('TEST 1. apply DeepStrictOmit to primitive property type of branding type', () => { 2 type TestInterface = { 3 id: string; 4 title: string; 5 thumbnails: { 6 name: null | (string & MinLength<1> & MaxLength<255>); 7 extension: null | (string & MinLength<1> & MaxLength<8>); 8 url: string; 9 }[]; 10 }; 11 12 type Question = DeepStrictOmit<TestInterface, 'id'>; 13 type IsAnswer = Equal< 14 Question, 15 { 16 title: string; 17 thumbnails: { 18 name: null | (string & MinLength<1> & MaxLength<255>); 19 extension: null | (string & MinLength<1> & MaxLength<8>); 20 url: string; 21 }[]; 22 } 23 >; 24 25 ok(typia.random<IsAnswer>()); 26});
DeepStrictPick<T, K>
creates a new type by selecting only the properties corresponding to the key K from object T, while preserving the nested structure. It allows safely selecting specific keys even from deep objects.
1type Example = { 2 user: { 3 name: string; 4 age: number; 5 }; 6}; 7 8// Result: { user: { name: string; } } 9type Picked = DeepStrictPick<Example, 'user.name'>;
DeepStrictUnbrand
1type BrandedType = { brand: number & { type: 'won' } }; 2 3// Result: { value: number; } 4type Unbranded = DeepStrictUnbrand<BrandedType>;
ElementOf
1type ArrayExample = string[]; 2 3// Result: string 4type ElementType = ElementOf<ArrayExample>;
Equal<A, B> evaluates whether types A and B are the same and returns true or false. This is used to validate whether two types are identical.
1type A = { a: number }; 2type B = { a: number }; 3 4// Result: true 5type AreEqual = Equal<A, B>;
No vulnerabilities found.
No security vulnerabilities found.