{"id":21762873,"url":"https://github.com/lccodder/typing-assets","last_synced_at":"2026-02-19T00:34:04.576Z","repository":{"id":243511118,"uuid":"807752704","full_name":"LCcodder/typing-assets","owner":"LCcodder","description":"TypeScript library with additional utility types and predicators generation","archived":false,"fork":false,"pushed_at":"2024-12-17T19:15:32.000Z","size":149,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-11T01:55:21.194Z","etag":null,"topics":["advanced-types","assets","jest-tests","nodejs","react","type-guard","type-guards","typescript","typescript-library","utility","utility-types"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LCcodder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-29T17:46:14.000Z","updated_at":"2024-12-17T19:15:36.000Z","dependencies_parsed_at":"2024-06-09T14:21:31.505Z","dependency_job_id":"cd8e72a2-8822-4cad-b29b-b1a64f30bfc7","html_url":"https://github.com/LCcodder/typing-assets","commit_stats":null,"previous_names":["lccodder/typing-assets"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/LCcodder/typing-assets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCcodder%2Ftyping-assets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCcodder%2Ftyping-assets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCcodder%2Ftyping-assets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCcodder%2Ftyping-assets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LCcodder","download_url":"https://codeload.github.com/LCcodder/typing-assets/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCcodder%2Ftyping-assets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29599373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T22:25:43.180Z","status":"ssl_error","status_checked_at":"2026-02-18T22:25:42.766Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advanced-types","assets","jest-tests","nodejs","react","type-guard","type-guards","typescript","typescript-library","utility","utility-types"],"created_at":"2024-11-26T12:13:22.940Z","updated_at":"2026-02-19T00:34:04.544Z","avatar_url":"https://github.com/LCcodder.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Typing Assets** - enhance your *TypeScript*\n### Powerful library for *TypeScript*, that provides better typing support with additional *utility generics* and *typing predicates*\n\nThis library was made for advanced *TypeScript* users, if you do not now what is *type guard*, *assert* keyword, *utility generics*, then you should read blogs below and then come back to this library\n+ [Utility types official docs]()\n+ [Asserters guide](https://blog.logrocket.com/assertion-functions-typescript/)\n+ [Type guards guide](https://blog.logrocket.com/how-to-use-type-guards-typescript/)\n---\n### What **Typing Assets** can do?\n\nAdditional **utility** types\n+ New utility types will make your type aggregation more comfortable\n+ You don't need to provide your own utility types in your project, just import this library\n+ Full type safety\n\nType **predicators generation**\n+ Now you don't need to write asserters and guards by your own, just use `generatePredicates` function, and it will generate both **guard** and **asserter** for your type based on given params\n+ You can generate **guard** or **asserter** separately\n+ Full type safety, just if like you writed the **guard**\n+ *Conditional* (custom) **type guard** generation by validation function\n+ ***100%* Test coverage**\n\n**Property aggregation** functions\n+ Pick and remove properties with *type safety*\n+ ***100%* Test coverage**\n\n### Install:\n```shell\nnpm i typing-assets\n```\n\n### Usage:\n```TypeScript\nimport {isSameType} from \"typing-assets/src\"\n\n// false\nisSameType(1, \"1\", [1])\n\n```\n+ Always use `import {...} from \"typing-assets/src\"` with `src` subdir\n\n### Documantation map:\n\u003e [**Utility types**](#utility-generic-types)\n\u003e\u003e [`DeepOptional`](#deepoptionalt) - makes all nested properties optional \n\u003e\u003e \n\u003e\u003e [`DeepRequired`](#deeprequiredt) - makes all nested properties required\n\u003e\u003e\n\u003e\u003e [`ValueOf`](#valueoft) - extracts union type of values from object\n\u003e\u003e\n\u003e\u003e [`FromArray`](#fromarrayt) - extracts union type from array\n\u003e\u003e \n\u003e\u003e [`ExcludeNullable`](#excludenullablet) - excludes all nested *nullable* types from unions in object\n\u003e\u003e\n\u003e\u003e [`ExcludeActual`](#excludeactualt) - excludes all nested *non-nullable* types from unions in object\n\u003e\u003e \n\u003e\u003e [`ActualReturnType`](#actualreturntypet) - return type of function without *Promise* generic and *Awaited* keyword\n\u003e\u003e \n\u003e [**Predicates**](#predicates)\n\u003e\u003e [`generateGuard`](#generateguard) - generates type guard function by provided type checking property and it's *primitive type*, for ex. `generateGuard(user, \"name\", \"string\")`\n\u003e\u003e\n\u003e\u003e [`generateConditionalGuard`](#generateconditionalguard) - generates type guard function by provided validation callback\n\u003e\u003e\n\u003e\u003e [`generateAsserter`](#generateasserter) - generates type asserter function by provided validation callback\n\u003e\u003e\n\u003e\u003e [`generatePredicates`](#generatepredicates) - generates both type asserter and guard. Has 2 overloads for generating by property primitive and by validation callback\n\u003e\u003e \n\u003e [**Property aggregators**](#property-aggergators)\n\u003e\u003e [`excludeProperties`](#excludeproperties) - excludes provided properties with type safety\n\u003e\u003e\n\u003e\u003e [`pickProperties`](#pickproperties) - picks provided properties with type safety\n---\n\n## Utility generic types:\n\n### `DeepOptional\u003cT\u003e`\n\nMaking all nested fields optional. Returns `T` type if it is not extending `object`\n```TypeScript\ntype User = {\n    name: string\n    age: number\n    cc: {\n        code: string\n        cvv: number\n    }\n}\n\n/*\n*  name?: string\n*  age?: number\n*  cc?: {\n*      code?: string\n*      cvv?: number\n*  }\n*/\ntype OptionalUser = DeepOptional\u003cUser\u003e\n```\n---\n### `DeepRequired\u003cT\u003e` \nMaking all nested fields required. Returns `T` type if it is not extending `object`\n```TypeScript\ntype User = {\n    name: string\n    age: number\n    cc?: {\n        code?: string\n        cvv: number\n    }\n}\n\n/*\n*  ...\n*  cc: {\n*      code: string\n*      cvv: number\n*  }\n*/\ntype RequiredlUser = DeepRequired\u003cUser\u003e\n```\n---\n### `ValueOf\u003cT\u003e` \nExports union of all possible values (works also with arrays)\n```TypeScript\n// type A = string\ntype A = ValueOf\u003cstring[]\u003e\n\n// type B = string | number\ntype B = ValueOf\u003c{ \"1\": \"1\", \"2\": 2 }\u003e\n```\n---\n\n### `FromArray\u003cT\u003e` \n\nExports value specifically from array. Returns `T` if it is not array\n```TypeScript\n// type A = string\ntype A = FromArray\u003cstring[]\u003e\n```\n---\n\n### `ExcludeNullable\u003cT\u003e` \n\nExcludes all nullable unions in nested fields\n\n```TypeScript\n/* a: {\n*    b: string;\n*    c: string;\n*  };\n*  x: number;\n*/\ntype A = ExcludeNullable\u003c\n    {\n        a: {\n            b: string |null | void \n            c: string\n        }\n        x: number undefined\n    }\n\u003e\n```\n\n---\n\n### `ExcludeActual\u003cT\u003e` \n\nExcludes all primitive types from union type in nested properties\n```TypeScript\n/*\n*  {\n*    a: {\n*        b: void | null;\n*        c: never;\n*    };\n*    x: undefined;\n*  }\n*/\ntype A = ExcludeActual\u003c\n    {\n        a: {\n            b: string | null | void \n            c: string\n        }\n        x: number | undefined\n    }\n\u003e\n```\n---\n### `ActualReturnType\u003cT\u003e` \n\nWorks like `ReturnType` but automatically resolves promises types and excludes nullable values\n```TypeScript\nfunction f (): Promise\u003cvoid | string | undefined\u003e\n// A = string\ntype A = ActualReturnType\u003ctypeof f\u003e\n```\n---\n\n## Predicates:\n\n\n+ Type guards and asserters works better with *branded types*, for more information about branded types you can check out [this](https://www.youtube.com/watch?v=rpw59rajUSI) video\n\n### `isSameType` \n\nTakes *1* to *n* arguments, returns *true* if arguments are same type, *false* if not\n```TypeScript\n// true\nconst foo = isSameType(\"a\", \"b\", \"\")\n\n// false\nconst bar = isSameType(\"a\", 1)\n```\n---\n\n### `generateGuard` \n\nGenerates `type guard` by *property and its primitive type* (basic type guard). Uses for \n```TypeScript\ntype User = {\n    name: string\n    age: number\n    cc: {\n        code: string\n        cvv: number\n    }\n}\n\nconst isUser = generateGuard(\n    \"name\", \"string\"\n)\n\n// true\nisUser({\n    name: \"Jason\",\n    age: 19,\n    cc: {\n        code: \"1234 5678 9101 1121\",\n        cvv: 890\n    }\n})\n```\n---\n\n### `generateConditionalGuard` \n\nGenerates `type guard` functions that guards *by the callback function provided in argument*\n```TypeScript\ntype User = {\n    name: string\n    age: number\n    cc: {\n        code: string\n        cvv: number\n    }\n}\n\nconst isUser = generateConditionalGuard(\n    (entity: unknown) =\u003e (entity as User).cc.code.startsWith(\"1\")\n)\n\n// true\nisUser({\n    name: \"Jason\",\n    age: 19,\n    cc: {\n        code: \"1234 5678 9101 1121\",\n        cvv: 890\n    }\n})\n\n```\n\n---\n### `generateAsserter` \n\nGenerates `type asserter`, that throws error if provided object *does not follow provided conditions* (opposite of `type guard`). `isValid` callback should be like in `generateConditionalGuard` function argument\n```TypeScript\ntype User = {\n    name: string\n    age: number\n    cc: {\n        code: string\n        cvv: number\n    }\n}\n\nconst assertUser = generateAsserter(\n    (source: unknown) =\u003e (source as User).сс.code.startsWith(\"34\"),\n    \"Your cc code does not starts with 34\"\n)\n\n// throw `Error(\"Your cc code does not starts with 34\")`\nassertUser({\n    name: \"Jason\",\n    age: 19,\n    cc: {\n        code: \"1234 5678 9101 1121\",\n        cvv: 890\n    }\n})\n```\n\n---\n\n### `generatePredicates` \nGenerates both *asserter* and *guard* for promoted type. Has 2 overloads. First generates predicates with provided *validator callback*, second generates predicates via provided property and its primitive type. Both overloads requires *error message* at first argument\n```TypeScript\ntype User = {\n    name: string\n    age: number\n    cc: {\n        code: string\n        cvv: number\n    }\n}\n\nconst predicates: Predicates\u003cUser\u003e = generatePredicates\u003cUser\u003e(\n    \"User is not 18 yo\",\n    (source: unknown) =\u003e {return (source as User).age \u003e 18}\n)\n\n\nconst user = {\n    name: \"Pedro\",\n    age: 17,\n    cc: {\n        code: \"1231 2312 3132\",\n        cvv: 123\n    }\n}\n\n// throws 'Error(\"User is not 18 yo\")'\npredicates.assert(user)\n\n// true\npredicates.guard(user)\n\n```\n\n---\n\n\n## Property aggergators\n\n+ This is the only feature in this library that may work with the *JavaScript*\n\n### `excludeProperties`\n\nExcludes properties from given object. Mutates original object and returns mutated value. Return value will be type safe as with `Omit\u003cT\u003e`\n\n```TypeScript\nconst user: User = {\n    name: \"Pedro\",\n    age: 17,\n    cc: {\n        code: \"1231 2312 3132\",\n        cvv: 123\n    }\n}\n/*\n* {\n*   name: \"Pedro\",\n*   age: 17,\n* }\n*/\nconst userWithoutCC: Omit\u003cUser, \"cc\"\u003e = excludeProperties(user)\n```\n---\n\n### `pickProperties`\n\nOpposite of `excludeProperties`, picks properties from original objects. Mutates original object and returns mutated value. Return value will be type safe as with `Pick\u003cT\u003e`\n\n```TypeScript\n\nconst user: User = {\n    name: \"Pedro\",\n    age: 17,\n    cc: {\n        code: \"1231 2312 3132\",\n        cvv: 123\n    }\n}\n/*\n* {\n*   name: \"Pedro\",\n*   age: 17,\n* }\n*/\nconst userWithoutCC: Pick\u003cUser, \"age\" | \"name\"\u003e = pickProperties(user, \"age\", \"name\")\n\n\n\n```\n---\nIf you have ideas for enhanching TypeScript with assets similar to those or upgrading current functional, contact me by email or make pull request to this repo. If you are adding new assets and tests running on GitHub Actions are not completing, your PR will be never approved.\n\nMade and documented by [**LCcodder**](https://github.com/LCcodder) 🩷\n\n## Donate:\n\n**ETH:** `0xE1A9C5ab7e13D6F0E7D8028247893F0B17906583` \n\n**BTC:** `bc1qm9qkflhhv4fypyqm55ukukfu08f3k4d9aycuys`\n\n**USDT (TRC-20):** `TT6U3gowuuqwDDpRMiwsffeYPjXAbuTq3i`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flccodder%2Ftyping-assets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flccodder%2Ftyping-assets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flccodder%2Ftyping-assets/lists"}