{"id":16989612,"url":"https://github.com/didas-git/typescript-reference","last_synced_at":"2025-03-22T03:10:27.349Z","repository":{"id":129291736,"uuid":"533456746","full_name":"Didas-git/typescript-reference","owner":"Didas-git","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-25T18:22:34.000Z","size":68,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T22:11:15.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Didas-git.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":"2022-09-06T18:37:19.000Z","updated_at":"2022-11-29T22:57:45.000Z","dependencies_parsed_at":"2023-04-25T04:47:53.226Z","dependency_job_id":null,"html_url":"https://github.com/Didas-git/typescript-reference","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Ftypescript-reference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Ftypescript-reference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Ftypescript-reference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Ftypescript-reference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Didas-git","download_url":"https://codeload.github.com/Didas-git/typescript-reference/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244898446,"owners_count":20528341,"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","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":[],"created_at":"2024-10-14T03:07:17.504Z","updated_at":"2025-03-22T03:10:27.343Z","avatar_url":"https://github.com/Didas-git.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typescript Reference\n\n- [Typescript Reference](#typescript-reference)\n  - [Basics](#basics)\n    - [Primitive Types](#primitive-types)\n    - [Type Declaration](#type-declaration)\n      - [Implicit](#implicit)\n      - [Explicit](#explicit)\n      - [Arrays](#arrays)\n      - [Tuples](#tuples)\n      - [Objects](#objects)\n      - [Unit Types](#unit-types)\n      - [`const` vs `let`](#const-vs-let)\n    - [Type Manipulation](#type-manipulation)\n      - [Type Alias](#type-alias)\n      - [Interfaces](#interfaces)\n      - [Intersection](#intersection)\n      - [Union](#union)\n      - [Optional](#optional)\n      - [Extends](#extends)\n      - [Implements](#implements)\n      - [Type Assertion](#type-assertion)\n        - [`as const`](#as-const)\n      - [`type` vs `interface`](#type-vs-interface)\n        - [Extending](#extending)\n        - [Adding fields](#adding-fields)\n        - [Augmenting Classes](#augmenting-classes)\n  - [Advanced](#advanced)\n    - [Utility Types](#utility-types)\n      - [Built-In](#built-in)\n        - [PropertyKey](#propertykey)\n        - [Awaited\\\u003cT\u003e](#awaitedt)\n        - [Partial\\\u003cT\u003e](#partialt)\n        - [Required\\\u003cT\u003e](#requiredt)\n        - [Readonly\\\u003cT\u003e](#readonlyt)\n        - [Record\\\u003cK, T\u003e](#recordk-t)\n        - [Pick\\\u003cT, K\u003e](#pickt-k)\n        - [Exclude\\\u003cU, E\u003e](#excludeu-e)\n        - [Omit\\\u003cT, K\u003e](#omitt-k)\n        - [Extract\\\u003cT, U\u003e](#extractt-u)\n        - [NonNullable\\\u003cT\u003e](#nonnullablet)\n        - [Parameters\\\u003cT\u003e](#parameterst)\n        - [ConstructorParameters\\\u003cT\u003e](#constructorparameterst)\n        - [ReturnType\\\u003cT\u003e](#returntypet)\n        - [InstanceType\\\u003cT\u003e](#instancetypet)\n        - [ThisParameterType\\\u003cT\u003e](#thisparametertypet)\n        - [OmitThisParameter\\\u003cT\u003e](#omitthisparametert)\n        - [ThisType\\\u003cT\u003e](#thistypet)\n  - [Main Sources](#main-sources)\n\nBasics\n------\n\nIn this chapter i will focus on just showing the pure basics of typescript, what you have/should know to get started creating your projects and some things to might be aware when you start to move to more advanced/complex types.\n\n### Primitive Types\n\nTypescript primitives are the same as the [javascript](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) primitives with some additions.\n\n- `string` -\nA string is a sequence of characters contained inside `\" \"`, `' '` or `` ` ` ``.\n\n```ts\nlet str = \"Any string\";\n```\n\n- `number` -\nA number in javascript is a [double-precision 64-bit floating point format (IEEE 754)](https://en.wikipedia.org/wiki/Double_precision_floating-point_format).\n\n```ts\nlet num = 3;\n```\n\n- `bigint` -\nA bigint is a integer represented in an [arbitrary precision format](https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic). In javascript is represented by a number followed by `n`\n\n```ts\nlet bint = 3n;\n```\n\n- `boolean` -\nA boolean is a type that can be either `true` or `false`.\n\n```ts\nlet bool = true;\n```\n\n- `object` -\nThe object primitive represents anything that has an index signature and isn't another primitive.\n\n```ts\nlet a: object;\n\na = \"\";\n//\n// Type 'string' is not assignable to type 'object'.\na = 3;\n//\n// Type 'number' is not assignable to type 'object'.\na = {};\na.foo();\n//^^^\n// Property 'foo' does not exist on type 'object'.\na[\"bar\"];\n//^^^^^^\n// Element implicitly has an 'any' type because expression of type '\"bar\"' can't be used to index type '{}'.\n//   Property 'bar' does not exist on type '{}'.\na();\n//\n// This expression is not callable.\n//   Type '{}' has no call signatures.\n```\n\n- `undefined` -\nUndefined is a [primitive](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) value automatically assigned to [variables](https://developer.mozilla.org/en-US/docs/Glossary/Variable) that have just been declared, or to formal [arguments](https://developer.mozilla.org/en-US/docs/Glossary/Argument) for which there are no actual arguments.\n\n```ts\n// In this case undefined has to be explicit declared because otherwise typescript will make it `any`, more on that in a moment\nlet u: undefined;\n```\n\n- `symbol` -\nA symbol can only be created using the `Symbol` constructor and it is always[^1] unique.\n\n```ts\nconst sym = Symbol();\n```\n\n- `unique symbol` -\nA unique symbol is a subtype of symbol and can only appear if explicit assigned and can only be assigned to a constant using `Symbol()` and `Symbol.for()`.\n\n```ts\nconst sym1: unique symbol = Symbol()\n\nlet sym2: unique symbol = Symbol()\n//  ^^^^\n// A variable whose type is a 'unique symbol' type must be 'const'.\n```\n\n- [`null`](https://developer.mozilla.org/en-US/docs/Glossary/Null) -\nA primitive type annotating that no memory address is assigned to this variable. It behaves similar to undefined however, it's considered an object.\n\n```ts\nconst n1 = null\n\n// For non constants you have to explicit say the type is null otherwise typescript will say its `any`\nlet n2: null = null;\n```\n\n- `any` -\nAs the name sugests, `any` can be assigned to any type and wont do any type checking assuming that you know the environment better than typescript. \n\n```ts\nlet a: any;\n\na = \"\";\na = 3;\na = {};\na.foo();\na[\"bar\"];\na();\n\nconst b: number = a;\n```\n\n- `unknown` -\nBasically the same as `any` but doesnt allow dot notation, indexing and assigning to other variables. Using `unknown` over `any` is highly recommended to prevent possible oversights.\n\n```ts\nlet a: unknown;\n\na = \"\";\na = 3;\na = {};\na.foo();\n//\n// Object is of type 'unknown'.\na[\"bar\"];\n//\n// Object is of type 'unknown'.\na();\n//\n// Object is of type 'unknown'.\n\nconst b: number = a\n//    ^\n// Type 'unknown' is not assignable to type 'number'.\n```\n\n- [`never`](https://www.typescriptlang.org/docs/handbook/2/functions.html#never) -\nThe never type can usually appear when union types have nothing left and can be used as a return type for functions that throw exeptions. The most comun use of `never` is on [conditional](#conditional-types) and [complex](#complex-types) types but more on that later.\n\n```ts\nfunction fail(msg: string): never {\n    throw new Error(msg)\n}\n\nfunction fn(x: string | number): void {\n    if (typeof x === \"string\") {\n        // do something\n    } else if (typeof x === \"number\") {\n        // do something else\n    } else {\n        x;\n//      ^? - (parameter) x: never\n    }\n}\n```\n\n- `void` -\n`void` is a typescript type that is used for functions that do not return anything or return functions that return void.\n\n```ts\nfunction returnVoid() {\n//       ^? - function returnVoid(): void\n    return;\n}\n```\n\n### Type Declaration\n\n#### Implicit\n\nAn implicit type declaration is when you declare a variable without providing a type directly and leaving that work to the compiler.\n\n```ts\nlet str = \"A string\";\n//  ^? - let str: string\n```\n\n#### Explicit\n\nAn explicit type declaration is when you declare a variable with an assigned type.\n\n```ts\nlet str: string = \"A string\";\n//  ^? - let str: string\n```\n\n#### Arrays\n\nDeclaring array types can be done in 2 ways:\n- Using the `Array` generic.\n- Using an array literal.\n\n```ts\nlet stringArray: Array\u003cstring\u003e;\nlet numberArray: number[];\nlet numberAndBooleanArray: Array\u003cnumber | boolean\u003e;\nlet stringAndBooleanArray: (string | boolean)[];\n```\n\n#### Tuples\n\nA tuple is a fixed length array that can have a unique type per element, there are however ways to define an infinite length tuple, however, is not recommended and you should use an [array](#arrays) instead.\n\n```ts\nlet tuple: [string, number, boolean] = [\"hello\", 3, true, \"world\"];\n//  ^^^^^\n// Type '[string, number, true, string]' is not assignable to type '[string, number, boolean]'.\n//   Source has 4 element(s) but target allows only 3.\ntuple = [\"hello\", true];\n//                ^^^^\n// Type 'boolean' is not assignable to type 'number'.\n\nlet infiniteTuple: [string, ...Array\u003cnumber\u003e] = [\"hello\", 1, 2, 3];\ninfiniteTuple = [\"hello\", 1, 2, \"world\"];\n//^^^^^^^^^^^\n// Type '[string, number, number, string]' is not assignable to type '[string, ...number[]]'.\n//   Type at positions 1 through 3 in source is not compatible with type at position 1 in target.\n//     Type 'string | number' is not assignable to type 'number'.\n//       Type 'string' is not assignable to type 'number'.\n```\n\n#### Objects\n\nThere are 3 ways to declare object types, those being:\n- Using [`interfaces`](#interfaces) or [`type`](#type-alias) aliases.\n- Using object literals.\n- Using the `Record` generic.\n\n```ts\ninterface IObj {\n    a: string;\n    b: number\n}\n\ntype TObj = {\n    a: string,\n    b: number\n}\n\nlet iObj: IObj;\nlet tObj: TObj;\nlet normalObj: { a: string, b: number };\nlet recordObj: Record\u003cstring, string | number\u003e;\nlet recordObj2: Record\u003c\"a\" | \"b\", string | number\u003e\n```\n\nIf you want to create a variable that can store any object, using `Record` is highly recommended over the `object` type.\n\n```ts\nlet obj: object = {};\nobj = [];\n\n// More on 'Record' and 'PropertyKey' later\nlet record: Record\u003cPropertyKey, unknown\u003e = {};\nrecord = [];\n//^^^^\n// Type 'never[]' is not assignable to type 'Record\u003cPropertyKey, unknown\u003e'.\n//   Index signature for type 'string' is missing in type 'never[]'.\n```\n\n#### Unit Types\n\nUnit types are subsets of [primitive types](#primitive-types) that can only contain one value.\n\n```ts\nlet foo = \"foo\";\n//  ^? - let foo: string\n\nlet bar: \"bar\";\n//  ^? - let bar: \"bar\"\n\nbar = foo\n//^\n// Type 'string' is not assignable to type '\"bar\"'.\n```\n\n#### `const` vs `let`\n\nIn vanilla javascript the main difference between using `const` and `let` is that you cannot reassing nor redeclare a `const`, however, typescript adds another main difference.\\\nValues assigned to a `const` will turn into [`unit types`](#unit-types) when possible[^2], while `let` will be assigned to its [`primitive`](#primitive-types) type.\n\n```ts\nconst foo = \"foo\";\n//    ^? - const foo: \"foo\"\nlet bar = \"bar\";\n//  ^? - let bar: string\n\nconst num = 3;\n//    ^? - const num: 3\nlet lnum = 3;\n//  ^? - let lnum: number\n\nconst obj = { a: \"hello\", b: 3 }\n//    ^? - const obj: {\n//        a: string;\n//        b: number;\n//    }\n```\n\n### Type Manipulation\n\n#### [Type Alias](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-aliases)\n\nThe `type` keyword is used to create and name any type but as it is only an alias, it cannot be used to create  different or unique versions of the same type.\n\n```ts\ntype Point = {\n    x: number,\n    y: number\n};\n\ntype ConcatenatedString = string;\n\nfunction concat(str1: string, str2: string): ConcatenatedString {\n  return str1 + str2;\n}\n\n// Create a sanitized input\nlet helloWorld = concat(\"hello \", \"world\");\n \n// Can still be re-assigned with a string though\nhelloWorld = \"Hello\";\n```\n\n#### [Interfaces](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#interfaces)\n\nAn `interface` declaration is another way to declare a type and it's mostly used to declare object types. They can be extended by other interfaces and implemented in classes using the implements keyword.\n\n```ts\ninterface Point {\n    x: number;\n    y: number;\n}\n```\n\n#### Intersection\n\nThe intersection operator (`\u0026`) can be used just like the `extends` keyword but for type alises instead of classes.\n\n```ts\ninterface Circle {\n    radius: number;\n}\n\ninterface Colors {\n    r: number;\n    g: number;\n    b: number;\n}\n\ntype ColorfullCircle = Circle \u0026 Colors;\n\n// It can also be used inside function arguments and return types\nfunction draw(circle: Circle \u0026 Colors): Circle \u0026 Colors {\n    return circle;\n}\n\ndraw({ radius: 30 });\n//   ^^^^^^^^^^^^^^\n// Argument of type '{ radius: number; }' is not assignable to parameter of type 'Circle \u0026 Colors'.\n//   Type '{ radius: number; }' is missing the following properties from type 'Colors': r, g, b\n```\n\n#### Union\n\nThe union operator (`|`) in typescript works like an `or`.\\\nWhen paired with `never` a union type will ignore it and removei t from the union.\n\n```ts\ntype StringOrNumber = string | number;\n\nlet a: StringOrNumber = \"A string\";\na = 3;\na = true;\n//\n// Type 'boolean' is not assignable to type 'StringOrNumber'.\na = {};\n//\n// Type '{}' is not assignable to type 'StringOrNumber'.\n\n// As you can see the `never` is excluded\ntype BooleanOrNumber = boolean | never | number;\n//   ^? - type BooleanOrNumber = number | boolean\n\n// It can also be used inside function arguments and return types\nfunction stringOrNumber(o: string | number): string | number {\n    return o;\n}\n```\n\n#### Optional\n\nIn typescript you can use `?` on a property to make it optional.\\\nOn a side note, making a type `undefined` doesnt mean it is optional even tho optional types may show as possibly `undefined`.\n\n```ts\ninterface User {\n    name: string;\n    age?: number;\n    genre: string | undefined;\n}\n\nconst user1: User = {\n    name: \"Martin\",\n    genre: undefined,\n}\n\nconst user2: User = {\n//    ^^^^^\n// Property 'genre' is missing in type '{ name: string; }' but required in type 'User'.\n    name: \"Niek\",\n}\n\n```\n\n#### Extends\n\nThe `extends` keyword can be used in 2 ways:\n- [Conditional Types](#conditional-types) that will be covered later on.\n- Extend interfaces.\n\nExtending interfaces works just like extending classes in vanilla javascript but with the difference that you can extend multiple interfaces.\n\n```ts\ninterface Label {\n    labelName: string;\n    date: string;\n}\n\ninterface Artist {\n    artistName: string;\n} \n\ninterface Song extends Label, Artist {\n    songName: string;\n    realeseDate: Date;\n}\n```\n\n#### Implements\n\nThe `implements` keyword can be used to make sure than a class satisfies the definition of the given interface/type.\n\n```ts\ninterface Foo {\n    foo: () =\u003e void;\n}\n\ntype Bar = {\n    bar: () =\u003e void\n}\n\nclass MyClass implements Foo, Bar {\n//    ^^^^^^^\n// Class 'MyClass' incorrectly implements interface 'Bar'.\n//   Property 'bar' is missing in type 'MyClass' but required in type 'Bar'.\n    foo() {\n        return;\n    }\n}\n```\n\n#### Type Assertion\n\nType assertion can be used to convert one type to another. In very unique cases you might need to cast to `unknown` first, however, it's not recommended.\\\nType assertion can be done in 2 ways:\n- Using `\u003c\u003e` (only works on non JSX/TSX files).\n- Using the `as` keyword.\n\n```ts\nconst a = \u003cnumber\u003e\"hello\";\n//        ^^^^^^^^^^^^^^^\n// Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.\nconst b = \u003cnumber\u003e\u003cunknown\u003e\"hello\";\nconst x = \"hello\" as number;\n//        ^^^^^^^^^^^^^^^^^\n// Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.\nconst y = \"hello\" as unknown as number;\n```\n\n##### `as const`\n\nThe `as const` assertion can be used to make a variable readonly and also preserve its types.\n\n```ts\nconst obj = { a: \"hello\", b: 3 } as const\n//    ^? - const obj: {\n//        readonly a: \"hello\";\n//        readonly b: 3;\n//    }\n\nlet otherObj = { a: 3, b: \"hello\" } as const\n//  ^? - let otherObj: {\n//      readonly a: 3;\n//      readonly b: \"hello\";\n//  }\n```\n\n#### `type` vs `interface`\n\nType alias and interface are pretty simillar, the main differences are:\n- A type cannot be extended (using the `extends` keyword).\n- A type cannot have duplicate identifiers.\n- A type does not augment a class with the same name.\n\n##### Extending\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eInterfaces\u003c/th\u003e\n\u003cth\u003eTypes\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```ts\ninterface Animal {\n    name: string;\n}\n\ninterface Cat extends Animal {\n    race: string;\n}\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```ts\ntype Animal = {\n    name: string\n}\n\ntype Cat = Animal \u0026 {\n    race: string\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n##### Adding fields\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eInterfaces\u003c/th\u003e\n\u003cth\u003eTypes\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```ts\ninterface Story {\n    title: string;\n}\n\ninterface Story {\n    body: string;\n}\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```ts\ntype Story = {\n//   ^^^^^\n// Duplicate identifier 'Story'.\n    title: string\n}\n\ntype Story = {\n//   ^^^^^\n// Duplicate identifier 'Story'.\n    body: string\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n##### Augmenting Classes\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eInterfaces\u003c/th\u003e\n\u003cth\u003eTypes\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```ts\ninterface MyClass {\n    foo: () =\u003e void;\n    bar(): void;\n}\n\nclass MyClass {\n    bazz() {\n        return;\n    }\n}\n\nconst myClassInstance = new MyClass();\n\nmyClassInstance.foo();\nmyClassInstance.bar();\nmyClassInstance.bazz();\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```ts\ntype MyClass = {\n//   ^^^^^^^\n// Duplicate identifier 'MyClass'.\n    foo: () =\u003e void;\n    bar(): void;\n}\n\nclass MyClass {\n//    ^^^^^^^\n// Duplicate identifier 'MyClass'.\n    bazz() {\n        return;\n    }\n}\n\nconst myClassInstance = new MyClass();\n//                          ^^^^^^^\n// 'MyClass' only refers to a type, but is being used as a value here.\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\nAdvanced\n--------\n\n### Utility Types\n\nUtility types are types made to help commun manipulations.\\\nThe idea of this chapter is to show how they are made and explain how they work.\n\n#### Built-In\n\n##### PropertyKey\n\n```ts\ntype PropertyKey = string | number | symbol;\n\n// This is the same as:\ntype PropertyKey = keyof any;\n//   ^? - type PropertyKey = string | number | symbol\n```\n\n##### Awaited\\\u003cT\u003e\n\n```ts\ntype Awaited\u003cT\u003e = T extends null | undefined\n    ? T\n        : T extends object \u0026 { then(onfulfilled: infer F): any }\n            ? F extends ((value: infer V, ...args: any) =\u003e any) \n                ? Awaited\u003cV\u003e\n                : never\n        :T;\n```\n\n##### Partial\\\u003cT\u003e\n\n```ts\ntype Partial\u003cT\u003e = {\n    [P in keyof T]?: T[P];\n};\n```\n\n##### Required\\\u003cT\u003e\n\n```ts\ntype Required\u003cT\u003e = {\n    [P in keyof T]-?: T[P];\n};\n```\n\n##### Readonly\\\u003cT\u003e\n\n```ts\ntype Readonly\u003cT\u003e = {\n    readonly [P in keyof T]: T[P];\n};\n```\n\n##### Record\\\u003cK, T\u003e\n\n```ts\ntype Record\u003cK extends keyof any, T\u003e = {\n    [P in K]: T;\n};\n```\n\n##### Pick\\\u003cT, K\u003e\n\n```ts\ntype Pick\u003cT, K extends keyof T\u003e = {\n    [P in K]: T[P];\n};\n```\n\n##### Exclude\\\u003cU, E\u003e\n\n```ts\ntype Exclude\u003cU, E\u003e = U extends E ? never : U;\n```\n\n##### Omit\\\u003cT, K\u003e\n\n```ts\ntype Omit\u003cT, K extends keyof any\u003e = Pick\u003cT, Exclude\u003ckeyof T, K\u003e\u003e;\n```\n\n##### Extract\\\u003cT, U\u003e\n\n```ts\ntype Extract\u003cT, U\u003e = T extends U ? T : never;\n```\n\n##### NonNullable\\\u003cT\u003e\n\n```ts\ntype NonNullable\u003cT\u003e = T \u0026 {};\n```\n\n##### Parameters\\\u003cT\u003e\n\n```ts\ntype Parameters\u003cT extends (...args: any) =\u003e any\u003e = T extends (...args: infer P) =\u003e any ? P : never;\n```\n\n##### ConstructorParameters\\\u003cT\u003e\n\n```ts\ntype ConstructorParameters\u003cT extends abstract new (...args: any) =\u003e any\u003e = T extends abstract new (...args: infer P) =\u003e any ? P : never;\n```\n\n##### ReturnType\\\u003cT\u003e\n\n```ts\ntype ReturnType\u003cT extends (...args: any) =\u003e any\u003e = T extends (...args: any) =\u003e infer R ? R : any;\n```\n\n##### InstanceType\\\u003cT\u003e\n\n```ts\ntype InstanceType\u003cT extends abstract new (...args: any) =\u003e any\u003e = T extends abstract new (...args: any) =\u003e infer R ? R : any;\n```\n\n##### ThisParameterType\\\u003cT\u003e\n\n```ts\ntype ThisParameterType\u003cT\u003e = T extends (this: infer U, ...args: never) =\u003e any ? U : unknown;\n```\n\n##### OmitThisParameter\\\u003cT\u003e\n\n```ts\ntype OmitThisParameter\u003cT\u003e = unknown extends ThisParameterType\u003cT\u003e ? T : T extends (...args: infer A) =\u003e infer R ? (...args: A) =\u003e R : T;\n```\n\n##### ThisType\\\u003cT\u003e\n\n```ts\ninterface ThisType\u003cT\u003e { }\n```\n\nMain Sources\n------------\n[**`MDN`**](https://developer.mozilla.org/)\\\n[**`TS Handbook`**](https://www.typescriptlang.org/docs/handbook)\n\n[^1]: `Symbol.for` can bypass this unique behaviour, read the [MDN Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for) for more information.\n[^2]: By default `objects` will work the same in `const` as they do in `let`, however, this can be changed by using [`as const`](#as-const).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidas-git%2Ftypescript-reference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidas-git%2Ftypescript-reference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidas-git%2Ftypescript-reference/lists"}