Package Exports
- @kakasoo/deep-strict-types
- @kakasoo/deep-strict-types/bin/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@kakasoo/deep-strict-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
DeepStrictTypes
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.
DeepStrictObjectKeys
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.
type Example = {
user: {
name: string;
address: {
city: string;
zip: number;
};
};
};
// Result: "user" | "user.name" | "user.address" | "user.address.city" | "user.address.zip"
type Keys = DeepStrictObjectKeys<Example>;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.
type Example = {
user: {
name: string;
age: number;
};
};
// Result: { user: { age: number; } }
type Omitted = DeepStrictOmit<Example, "user.name">;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.
type Example = {
user: {
name: string;
age: number;
};
};
// Result: { user: { name: string; } }
type Picked = DeepStrictPick<Example, "user.name">;DeepStrictUnbrand
DeepStrictUnbrand
type BrandedType = { brand: number & { type: "won" } };
// Result: { value: number; }
type Unbranded = DeepStrictUnbrand<BrandedType>;SubTypes for implementation
ElementOf
ElementOf
type ArrayExample = string[];
// Result: string
type ElementType = ElementOf<ArrayExample>;Equal
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.
type A = { a: number };
type B = { a: number };
// Result: true
type AreEqual = Equal<A, B>;