New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@kakasoo/deep-strict-types

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kakasoo/deep-strict-types - npm Package Compare versions

Comparing version 1.0.20 to 1.0.21

35

package.json
{
"name": "@kakasoo/deep-strict-types",
"version": "1.0.20",
"version": "1.0.21",
"description": "",

@@ -21,4 +21,29 @@ "private": false,

},
"keywords": [],
"author": "",
"keywords": [
"typescript",
"types",
"utility-types",
"deep-types",
"nested-types",
"type-safety",
"type-checking",
"strict-types",
"deep-strict",
"deep-pick",
"deep-omit",
"deep-keys",
"deep-object",
"type-utils",
"type-helpers",
"typescript-utils",
"typescript-types",
"type-manipulation",
"nested-objects",
"object-types",
"array-types",
"type-inference",
"type-assertions",
"type-validation"
],
"author": "kakasoo",
"license": "ISC",

@@ -34,2 +59,6 @@ "devDependencies": {

},
"repository": {
"type": "git",
"url": "https://github.com/kakasoo/deepstricttypes"
},
"dependencies": {

@@ -36,0 +65,0 @@ "@kakasoo/proto-typescript": "^1.28.7"

73

README.md

@@ -9,3 +9,3 @@ # How To Use

**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.
**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!**

@@ -18,9 +18,9 @@ ## DeepStrictObjectKeys

type Example = {
user: {
name: string;
address: {
city: string;
zip: number;
};
user: {
name: string;
address: {
city: string;
zip: number;
};
};
};

@@ -32,32 +32,65 @@

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
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.
`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.
```ts
type Example = {
user: {
name: string;
age: number;
};
user: {
name: string;
age: number;
};
};
// Result: { user: { age: number; } }
type Omitted = DeepStrictOmit<Example, "user.name">;
type 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.
```ts
test('TEST 1. apply DeepStrictOmit to primitive property type of branding type', () => {
type TestInterface = {
id: string;
title: string;
thumbnails: {
name: null | (string & MinLength<1> & MaxLength<255>);
extension: null | (string & MinLength<1> & MaxLength<8>);
url: string;
}[];
};
type Question = DeepStrictOmit<TestInterface, 'id'>;
type IsAnswer = Equal<
Question,
{
title: string;
thumbnails: {
name: null | (string & MinLength<1> & MaxLength<255>);
extension: null | (string & MinLength<1> & MaxLength<8>);
url: string;
}[];
}
>;
ok(typia.random<IsAnswer>());
});
```
## DeepStrictPick
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.
`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.
```ts
type Example = {
user: {
name: string;
age: number;
};
user: {
name: string;
age: number;
};
};
// Result: { user: { name: string; } }
type Picked = DeepStrictPick<Example, "user.name">;
type Picked = DeepStrictPick<Example, 'user.name'>;
```

@@ -70,3 +103,3 @@

```ts
type BrandedType = { brand: number & { type: "won" } };
type BrandedType = { brand: number & { type: 'won' } };

@@ -73,0 +106,0 @@ // Result: { value: number; }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc