{"id":26610375,"url":"https://github.com/bodnya29179/typescript-types-deep-dive","last_synced_at":"2025-10-06T08:15:40.352Z","repository":{"id":189403077,"uuid":"680484658","full_name":"bodnya29179/TypeScript-Types-Deep-Dive","owner":"bodnya29179","description":"🕵️‍♂️ Dive into advanced TypeScript types – Utility Types, Generics, Operators, and more. Master type theory through concise examples and hands-on exercises.","archived":false,"fork":false,"pushed_at":"2025-03-29T22:28:36.000Z","size":135,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T23:50:35.504Z","etag":null,"topics":["deep-dive","generics","types","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bodnya29179.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2023-08-19T11:51:46.000Z","updated_at":"2025-03-29T22:28:39.000Z","dependencies_parsed_at":"2025-03-19T16:27:37.412Z","dependency_job_id":"700a6982-eadd-4158-b224-9085db8d16f2","html_url":"https://github.com/bodnya29179/TypeScript-Types-Deep-Dive","commit_stats":null,"previous_names":["bodnya29179/typescript-types-deep-dive"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bodnya29179/TypeScript-Types-Deep-Dive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodnya29179%2FTypeScript-Types-Deep-Dive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodnya29179%2FTypeScript-Types-Deep-Dive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodnya29179%2FTypeScript-Types-Deep-Dive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodnya29179%2FTypeScript-Types-Deep-Dive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bodnya29179","download_url":"https://codeload.github.com/bodnya29179/TypeScript-Types-Deep-Dive/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodnya29179%2FTypeScript-Types-Deep-Dive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278578016,"owners_count":26009719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["deep-dive","generics","types","typescript"],"created_at":"2025-03-24T01:39:35.035Z","updated_at":"2025-10-06T08:15:40.314Z","avatar_url":"https://github.com/bodnya29179.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript: Types Deep Dive\n\n## Why do we need it?\n\nIt equips you with key insights and skills to effectively utilize TypeScript types for enhanced code quality and efficiency.\n\n![TypeScript \"any\"](./images/ts-any.jpg)\n\n## Structure of files\n\n- ### **Basics**:\n  \n  Important TypeScript topics for mastering further higher-level topics.\n  \n  Files: `00-*.ts` - `12-*.ts`.\n\n- ### **Advanced**:\n\n  Top-level topics about types in TypeScript.\n\n  Files: `13-*.ts` - `18-*.ts`.\n\n- ### **Homework**: \n\n  Tasks that you can practice and think about.\n\n## Definitions\n\n### \\\u003e Types union\n\n`Types union` is a way to declare a type that can hold **values of multiple specified types**, allowing for greater\nflexibility in variable and parameter declarations.\n\n```typescript\ninterface Car {\n  type: 'car';\n  brand: 'mercedes';\n}\n\ninterface Bike {\n  type: 'bike';\n  model: 'mountain';\n}\n\ntype VehicleType = Car | Bike;\n\nconst vehicle: VehicleType = {\n  type: 'car',\n  brand: 'mercedes',\n};\n```\n\n### \\\u003e Keyof\n\n`keyof` is a keyword which is used to extract the key type from an object type.\n\n```typescript\nkeyof Something\n```\n\n### \\\u003e Typeof\n\n`typeof` is a keyword which is used to check the type of variable.\n\n```typescript\ntypeof Something\n```\n\n### \\\u003e Types intersection\n\n`Types intersection` is a way to declare a type that combines multiple types into a single type that contains all the\nproperties and characteristics of each individual type.\n\n```typescript\ninterface Person {\n  name: string;\n}\n\ninterface Address {\n  street: string;\n  city: string;\n}\n\ntype PersonWithAddressType = Person \u0026 Address;\n\nconst person: PersonWithAddressType = {\n  name: 'John',\n  street: 'Main St.',\n  city: 'New York',\n};\n```\n\n### \\\u003e Types assertion\n\n`Types assertion`  is the explicit specification of a value's type to temporarily override the type inferred by the\nTypeScript compiler, aiding in type-safe interactions with values.\n\n```typescript\ninterface User {\n  name: string;\n}\n\nconst user = {\n  name: 'John',\n  age: 15,\n} as User;\n```\n\n### \\\u003e Const assertion\n\n`Const assertion` is a way to tell the type system that a variable should not have its type widened,\npreserving its literal value as the most specific type.\n\n```typescript\nconst userPermissions = ['admin', 'user'] as const;\n```\n\n### \\\u003e Tuples\n\n`Tuple` is a typed array with a pre-defined length and types for each index.\n\n```typescript\nconst person: [string, number, boolean] = ['John', 20, true];\n```\n\n### \\\u003e Literal Types\n\n`Literal Types` allows us to create more precise types like type combinations using template literals.\n\n```typescript\ntype LiteralType = `${Type1}-${Type2}`;\n```\n\n### \\\u003e Utility types\n\n#### Partial\n\n`Partial` changes all the properties in an object to be optional.\n\n```typescript\nPartial\u003cType\u003e\n```\n\n#### Required\n\n`Required` changes all the properties in an object to be required.\n\n```typescript\nRequired\u003cType\u003e\n```\n\n#### Record\n\n`Record` is a shortcut to defining an object type with a specific key type and value type.\n\n```typescript\nRecord\u003cKeyType, ValueType\u003e\n```\n\n#### Omit\n\n`Omit` removes keys from an object type.\n\n```typescript\nOmit\u003cType, Keys\u003e\n```\n\n#### Pick\n\n`Pick` removes all but the specified keys from an object type.\n\n```typescript\nPick\u003cType, Keys\u003e\n```\n\n#### Exclude\n\n`Exclude` removes types from a union.\n\n```typescript\nExclude\u003cUnionType, ExcludedMembers\u003e\n```\n\n#### Extract\n\n`Extract` constructs a type by extracting from `Type` all union members that are assignable to `UnionType`.\n\n```typescript\nExtract\u003cType, UnionType\u003e\n```\n\n#### ReturnType\n\n`ReturnType` extracts the return type of function type.\n\n```typescript\nReturnType\u003cType\u003e\n```\n\n#### Parameters\n\n`Parameters` extracts the parameter types of a function type as an array.\n\n```typescript\nParameters\u003cType\u003e\n```\n\n#### Readonly\n\n`Readonly` is used to create a new type where all properties are readonly, meaning they cannot be modified once assigned\na value.\n\n```typescript\nParameters\u003cType\u003e\n```\n\n#### Awaited\n\n`Readonly` is meant to model operations like await in async functions, or the .then() method on Promises - specifically,\nthe way that they recursively unwrap Promises.\n\n```typescript\nAwaited\u003cType\u003e\n```\n\n#### Other utilities \u003cins\u003efor self-processing\u003c/ins\u003e:\n```typescript\nExtract\u003cType, Union\u003e\n```\n\n```typescript\nNonNullable\u003cType\u003e\n```\n\n```typescript\nInstanceType\u003cType\u003e\n```\n\n```typescript\nUppercase\u003cStringType\u003e\n```\n\n```typescript\nLowercase\u003cStringType\u003e\n```\n\n```typescript\nCapitalize\u003cStringType\u003e\n```\n\n```typescript\nUncapitalize\u003cStringType\u003e\n```\n\n### \\\u003e Indexed access types\n\n`Indexed access types` can be used to look up a specific property on another type.\n\n```typescript\nType['property']\n```\n\n### \\\u003e Generics\n\n`Generics` are a mechanism that allows you to create generic types or functions that can work with different data types\nwhile maintaining type safety. They allow you to provide compile-time type checking and use this type information to\nimprove data handling.\n\n## References\n\n1. [Unions and Intersection Types](https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html).\n2. [Utility Types](https://www.typescriptlang.org/docs/handbook/utility-types.html).\n3. [TypeScript Book](https://github.com/gibbok/typescript-book).\n4. [Indexed Access Types](https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html).\n5. [Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html).\n\n## Repository link\n\n🔗 https://github.com/bodnya29179/TypeScript-Types-Deep-Dive\n\n**or**\n\n![Repo link](./images/qr-code.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodnya29179%2Ftypescript-types-deep-dive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbodnya29179%2Ftypescript-types-deep-dive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodnya29179%2Ftypescript-types-deep-dive/lists"}