{ "manifest": { "name": "type-fest", "version": "2.19.0", "description": "A collection of essential TypeScript types", "license": "(MIT OR CC0-1.0)", "repository": { "type": "git", "url": "https://github.com/sindresorhus/type-fest.git" }, "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "engines": { "node": ">=12.20" }, "scripts": { "test": "xo && tsd && tsc && node script/test/source-files-extension.js" }, "files": [ "index.d.ts", "source" ], "keywords": [ "typescript", "ts", "types", "utility", "util", "utilities", "omit", "merge", "json" ], "devDependencies": { "@sindresorhus/tsconfig": "~0.7.0", "expect-type": "^0.13.0", "tsd": "^0.20.0", "typescript": "^4.6.3", "xo": "^0.43.0" }, "types": "./index.d.ts", "xo": { "rules": { "@typescript-eslint/ban-types": "off", "@typescript-eslint/indent": "off", "node/no-unsupported-features/es-builtins": "off", "import/extensions": "off", "@typescript-eslint/no-redeclare": "off", "@typescript-eslint/no-confusing-void-expression": "off" } }, "_registry": "npm", "_loc": "/home/josie/.cache/yarn/v6/npm-type-fest-2.19.0-88068015bb33036a598b952e55e9311a60fd3a9b-integrity/node_modules/type-fest/package.json", "readmeFilename": "readme.md", "readme": "
\n\t
\n\t
\n\t\"type-fest\"\n\t
\n\t
\n\tA collection of essential TypeScript types\n\t
\n\t
\n\t
\n\t
\n\t
\n\t
\n\t\t

\n\t\t\t

\n\t\t\t\t\n\t\t\t\t\tSindre Sorhus' open source work is supported by the community\n\t\t\t\t\n\t\t\t

\n\t\t\tSpecial thanks to:\n\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\"WorkOS\"\n\t\t\t\t
\n\t\t\t\tYour app, enterprise-ready.\n\t\t\t\t
\n\t\t\t\t\tStart selling to enterprise customers with just a few lines of code.\n\t\t\t\t\t
\n\t\t\t\t\tAdd Single Sign-On (and more) in minutes instead of months.\n\t\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\"Anvil\"\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\tPaperwork that makes the data work.\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\tEasy APIs for paperwork. PDF generation, e-signature and embeddable no-code webforms.\n\t\t\t\t\t
\n\t\t\t\t\tThe easiest way to build paperwork automation into your product.\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\"Anvil\"\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\tPaperwork that makes the data work.\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\tEasy APIs for paperwork. PDF generation, e-signature and embeddable no-code webforms.\n\t\t\t\t\t
\n\t\t\t\t\tThe easiest way to build paperwork automation into your product.\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t

\n\t
\n\t
\n\t
\n
\n
\n
\n\n[![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://giphy.com/gifs/illustration-rainbow-unicorn-26AHG5KGFxSkUWw1i)\n[![npm dependents](https://badgen.net/npm/dependents/type-fest)](https://www.npmjs.com/package/type-fest?activeTab=dependents)\n[![npm downloads](https://badgen.net/npm/dt/type-fest)](https://www.npmjs.com/package/type-fest)\n[![Docs](https://paka.dev/badges/v0/cute.svg)](https://paka.dev/npm/type-fest)\n\nMany of the types here should have been built-in. You can help by suggesting some of them to the [TypeScript project](https://github.com/Microsoft/TypeScript/blob/main/CONTRIBUTING.md).\n\nEither add this package as a dependency or copy-paste the needed types. No credit required. 👌\n\nPR welcome for additional commonly needed types and docs improvements. Read the [contributing guidelines](.github/contributing.md) first.\n\n**Help wanted with reviewing [proposals](https://github.com/sindresorhus/type-fest/issues) and [pull requests](https://github.com/sindresorhus/type-fest/pulls).**\n\n## Install\n\n```sh\nnpm install type-fest\n```\n\n*Requires TypeScript >=4.2*\n\n## Usage\n\n```ts\nimport type {Except} from 'type-fest';\n\ntype Foo = {\n\tunicorn: string;\n\trainbow: boolean;\n};\n\ntype FooWithoutRainbow = Except;\n//=> {unicorn: string}\n```\n\n## API\n\nClick the type names for complete docs.\n\n### Basic\n\n- [`Primitive`](source/primitive.d.ts) - Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).\n- [`Class`](source/basic.d.ts) - Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n- [`Constructor`](source/basic.d.ts) - Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n- [`TypedArray`](source/typed-array.d.ts) - Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.\n- [`ObservableLike`](source/observable-like.d.ts) - Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).\n\n### Utilities\n\n- [`Except`](source/except.d.ts) - Create a type from an object type without certain keys. This is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys).\n- [`Writable`](source/writable.d.ts) - Create a type that strips `readonly` from all or some of an object's keys. The inverse of `Readonly`. Formerly named `Mutable`.\n- [`Merge`](source/merge.d.ts) - Merge two types into a new type. Keys of the second type overrides keys of the first type.\n- [`MergeExclusive`](source/merge-exclusive.d.ts) - Create a type that has mutually exclusive keys.\n- [`RequireAtLeastOne`](source/require-at-least-one.d.ts) - Create a type that requires at least one of the given keys.\n- [`RequireExactlyOne`](source/require-exactly-one.d.ts) - Create a type that requires exactly a single key of the given keys and disallows more.\n- [`RequireAllOrNone`](source/require-all-or-none.d.ts) - Create a type that requires all of the given keys or none of the given keys.\n- [`RemoveIndexSignature`](source/remove-index-signature.d.ts) - Create a type that only has explicitly defined properties, absent of any index signatures.\n- [`PartialDeep`](source/partial-deep.d.ts) - Create a deeply optional version of another type. Use [`Partial`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) if you only need one level deep.\n- [`PartialOnUndefinedDeep`](source/partial-on-undefined-deep.d.ts) - Create a deep version of another type where all keys accepting `undefined` type are set to optional.\n- [`ReadonlyDeep`](source/readonly-deep.d.ts) - Create a deeply immutable version of an `object`/`Map`/`Set`/`Array` type. Use [`Readonly`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype) if you only need one level deep.\n- [`LiteralUnion`](source/literal-union.d.ts) - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union. Workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729).\n- [`Opaque`](source/opaque.d.ts) - Create an [opaque type](https://codemix.com/opaque-types-in-javascript/).\n- [`UnwrapOpaque`](source/opaque.d.ts) - Revert an [opaque type](https://codemix.com/opaque-types-in-javascript/) back to its original type.\n- [`InvariantOf`](source/invariant-of.d.ts) - Create an [invariant type](https://basarat.gitbook.io/typescript/type-system/type-compatibility#footnote-invariance), which is a type that does not accept supertypes and subtypes.\n- [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional.\n- [`SetRequired`](source/set-required.d.ts) - Create a type that makes the given keys required.\n- [`SetNonNullable`](source/set-non-nullable.d.ts) - Create a type that makes the given keys non-nullable.\n- [`ValueOf`](source/value-of.d.ts) - Create a union of the given object's values, and optionally specify which keys to get the values from.\n- [`ConditionalKeys`](source/conditional-keys.d.ts) - Extract keys from a shape where values extend the given `Condition` type.\n- [`ConditionalPick`](source/conditional-pick.d.ts) - Like `Pick` except it selects properties from a shape where the values extend the given `Condition` type.\n- [`ConditionalExcept`](source/conditional-except.d.ts) - Like `Omit` except it removes properties from a shape where the values extend the given `Condition` type.\n- [`UnionToIntersection`](source/union-to-intersection.d.ts) - Convert a union type to an intersection type.\n- [`LiteralToPrimitive`](source/literal-to-primitive.d.ts) - Convert a [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types) to the [primitive type](source/primitive.d.ts) it belongs to.\n- [`Stringified`](source/stringified.d.ts) - Create a type with the keys of the given type changed to `string` type.\n- [`IterableElement`](source/iterable-element.d.ts) - Get the element type of an `Iterable`/`AsyncIterable`. For example, an array or a generator.\n- [`Entry`](source/entry.d.ts) - Create a type that represents the type of an entry of a collection.\n- [`Entries`](source/entries.d.ts) - Create a type that represents the type of the entries of a collection.\n- [`SetReturnType`](source/set-return-type.d.ts) - Create a function type with a return type of your choice and the same parameters as the given function type.\n- [`Simplify`](source/simplify.d.ts) - Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.\n- [`Get`](source/get.d.ts) - Get a deeply-nested property from an object using a key path, like [Lodash's `.get()`](https://lodash.com/docs/latest#get) function.\n- [`StringKeyOf`](source/string-key-of.d.ts) - Get keys of the given type as strings.\n- [`Schema`](source/schema.d.ts) - Create a deep version of another object type where property values are recursively replaced into a given value type.\n- [`Exact`](source/exact.d.ts) - Create a type that does not allow extra properties.\n- [`OptionalKeysOf`](source/optional-keys-of.d.ts) - Extract all optional keys from the given type.\n- [`HasOptionalKeys`](source/has-optional-keys.d.ts) - Create a `true`/`false` type depending on whether the given type has any optional fields.\n- [`RequiredKeysOf`](source/required-keys-of.d.ts) - Extract all required keys from the given type.\n- [`HasRequiredKeys`](source/has-required-keys.d.ts) - Create a `true`/`false` type depending on whether the given type has any required fields.\n- [`Spread`](source/spread.d.ts) - Mimic the type inferred by TypeScript when merging two objects or two arrays/tuples using the spread syntax.\n\n### JSON\n\n- [`Jsonify`](source/jsonify.d.ts) - Transform a type to one that is assignable to the `JsonValue` type.\n- [`JsonPrimitive`](source/basic.d.ts) - Matches a JSON primitive.\n- [`JsonObject`](source/basic.d.ts) - Matches a JSON object.\n- [`JsonArray`](source/basic.d.ts) - Matches a JSON array.\n- [`JsonValue`](source/basic.d.ts) - Matches any valid JSON value.\n\n### Async\n\n- [`Promisable`](source/promisable.d.ts) - Create a type that represents either the value or the value wrapped in `PromiseLike`.\n- [`AsyncReturnType`](source/async-return-type.d.ts) - Unwrap the return type of a function that returns a `Promise`.\n- [`Asyncify`](source/asyncify.d.ts) - Create an async version of the given function type.\n\n### String\n\n- [`Trim`](source/trim.d.ts) - Remove leading and trailing spaces from a string.\n- [`Split`](source/split.d.ts) - Represents an array of strings split using a given character or character set.\n- [`Replace`](source/replace.d.ts) - Represents a string with some or all matches replaced by a replacement.\n\n### Array\n\n- [`Includes`](source/includes.d.ts) - Returns a boolean for whether the given array includes the given item.\n- [`Join`](source/join.d.ts) - Join an array of strings and/or numbers using the given string as a delimiter.\n- [`LastArrayElement`](source/last-array-element.d.ts) - Extracts the type of the last element of an array.\n- [`FixedLengthArray`](source/fixed-length-array.d.ts) - Create a type that represents an array of the given type and length.\n- [`MultidimensionalArray`](source/multidimensional-array.d.ts) - Create a type that represents a multidimensional array of the given type and dimensions.\n- [`MultidimensionalReadonlyArray`](source/multidimensional-readonly-array.d.ts) - Create a type that represents a multidimensional readonly array of the given type and dimensions.\n- [`ReadonlyTuple`](source/readonly-tuple.d.ts) - Create a type that represents a read-only tuple of the given type and length.\n\n### Numeric\n\n- [`PositiveInfinity`](source/numeric.d.ts) - Matches the hidden `Infinity` type.\n- [`NegativeInfinity`](source/numeric.d.ts) - Matches the hidden `-Infinity` type.\n- [`Finite`](source/numeric.d.ts) - A finite `number`.\n- [`Integer`](source/numeric.d.ts) - A `number` that is an integer.\n- [`Float`](source/numeric.d.ts) - A `number` that is not an integer.\n- [`NegativeFloat`](source/numeric.d.ts) - A negative (`-∞ < x < 0`) `number` that is not an integer.\n- [`Negative`](source/numeric.d.ts) - A negative `number`/`bigint` (`-∞ < x < 0`)\n- [`NonNegative`](source/numeric.d.ts) - A non-negative `number`/`bigint` (`0 <= x < ∞`).\n- [`NegativeInteger`](source/numeric.d.ts) - A negative (`-∞ < x < 0`) `number` that is an integer.\n- [`NonNegativeInteger`](source/numeric.d.ts) - A non-negative (`0 <= x < ∞`) `number` that is an integer.\n\n### Change case\n\n- [`CamelCase`](source/camel-case.d.ts) - Convert a string literal to camel-case (`fooBar`).\n- [`CamelCasedProperties`](source/camel-cased-properties.d.ts) - Convert object properties to camel-case (`fooBar`).\n- [`CamelCasedPropertiesDeep`](source/camel-cased-properties-deep.d.ts) - Convert object properties to camel-case recursively (`fooBar`).\n- [`KebabCase`](source/kebab-case.d.ts) - Convert a string literal to kebab-case (`foo-bar`).\n- [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) - Convert a object properties to kebab-case recursively (`foo-bar`).\n- [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) - Convert object properties to kebab-case (`foo-bar`).\n- [`PascalCase`](source/pascal-case.d.ts) - Converts a string literal to pascal-case (`FooBar`)\n- [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) - Converts object properties to pascal-case (`FooBar`)\n- [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) - Converts object properties to pascal-case (`FooBar`)\n- [`SnakeCase`](source/snake-case.d.ts) - Convert a string literal to snake-case (`foo_bar`).\n- [`SnakeCasedProperties`](source/snake-cased-properties-deep.d.ts) - Convert object properties to snake-case (`foo_bar`).\n- [`SnakeCasedPropertiesDeep`](source/snake-cased-properties-deep.d.ts) - Convert object properties to snake-case recursively (`foo_bar`).\n- [`ScreamingSnakeCase`](source/screaming-snake-case.d.ts) - Convert a string literal to screaming-snake-case (`FOO_BAR`).\n- [`DelimiterCase`](source/delimiter-case.d.ts) - Convert a string literal to a custom string delimiter casing.\n- [`DelimiterCasedProperties`](source/delimiter-cased-properties.d.ts) - Convert object properties to a custom string delimiter casing.\n- [`DelimiterCasedPropertiesDeep`](source/delimiter-cased-properties-deep.d.ts) - Convert object properties to a custom string delimiter casing recursively.\n\n### Miscellaneous\n\n- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). It also includes support for [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) and [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/).\n- [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript 4.4).\n\n## Declined types\n\n*If we decline a type addition, we will make sure to document the better solution here.*\n\n- [`Diff` and `Spread`](https://github.com/sindresorhus/type-fest/pull/7) - The pull request author didn't provide any real-world use-cases and the PR went stale. If you think this type is useful, provide some real-world use-cases and we might reconsider.\n- [`Dictionary`](https://github.com/sindresorhus/type-fest/issues/33) - You only save a few characters (`Dictionary` vs `Record`) from [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type), which is more flexible and well-known. Also, you shouldn't use an object as a dictionary. We have `Map` in JavaScript now.\n- [`ExtractProperties` and `ExtractMethods`](https://github.com/sindresorhus/type-fest/pull/4) - The types violate the single responsibility principle. Instead, refine your types into more granular type hierarchies.\n- [`Url2Json`](https://github.com/sindresorhus/type-fest/pull/262) - Inferring search parameters from a URL string is a cute idea, but not very useful in practice, since search parameters are usually dynamic and defined separately.\n- [`Nullish`](https://github.com/sindresorhus/type-fest/pull/318) - The type only saves a couple of characters, not everyone knows what \"nullish\" means, and I'm also trying to [get away from `null`](https://github.com/sindresorhus/meta/discussions/7).\n- [`TitleCase`](https://github.com/sindresorhus/type-fest/pull/303) - It's not solving a common need and is a better fit for a separate package.\n- [`ExtendOr` and `ExtendAnd`](https://github.com/sindresorhus/type-fest/pull/247) - The benefits don't outweigh having to learn what they mean.\n- [`PackageJsonExtras`](https://github.com/sindresorhus/type-fest/issues/371) - There are too many possible configurations that can be put into `package.json`. If you would like to extend `PackageJson` to support an additional configuration in your project, please see the *Extending existing types* section below.\n\n## Alternative type names\n\n*If you know one of our types by a different name, add it here for discovery.*\n\n- `PartialBy` - See [`SetOptional`](https://github.com/sindresorhus/type-fest/blob/main/source/set-optional.d.ts)\n- `RecordDeep`- See [`Schema`](https://github.com/sindresorhus/type-fest/blob/main/source/schema.d.ts)\n\n## Tips\n\n### Extending existing types\n\n- [`PackageJson`](source/package-json.d.ts) - There are a lot of tools that place extra configurations inside the `package.json` file. You can extend `PackageJson` to support these additional configurations.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBDAnmApnA3gBQIYGMDW2A5igFIDOEAdnNuXAEJ0o4HFmVUC+cAZlBBBwA5ElQBaXinIxhAbgCwAKFCRYCZGnQAZYFRgooPfoJHSANntmKlysWlaESFanAC8jZo-YuaAMgwLKwBhal5gIgB+AC44XX1DADpQqnCiLhsgA)\n\n\t```ts\n\timport type {PackageJson as BasePackageJson} from 'type-fest';\n\timport type {Linter} from 'eslint';\n\n\ttype PackageJson = BasePackageJson & {eslintConfig?: Linter.Config};\n\t```\n\t
\n\n### Related\n\n- [typed-query-selector](https://github.com/g-plane/typed-query-selector) - Enhances `document.querySelector` and `document.querySelectorAll` with a template literal type that matches element types returned from an HTML element query selector.\n- [`Linter.Config`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eslint/index.d.ts) - Definitions for the [ESLint configuration schema](https://eslint.org/docs/user-guide/configuring/language-options).\n\n### Built-in types\n\nThere are many advanced types most users don't know about.\n\n- [`Partial`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) - Make all properties in `T` optional.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://www.typescriptlang.org/play/#code/JYOwLgpgTgZghgYwgAgHIHsAmEDC6QzADmyA3gLABQyycADnanALYQBcyAzmFKEQNxUaddFDAcQAV2YAjaIMoBfKlQQAbOJ05osEAIIMAQpOBrsUMkOR1eANziRkCfISKSoD4Pg4ZseAsTIALyW1DS0DEysHADkvvoMMQA0VsKi4sgAzAAMuVaKClY2wPaOknSYDrguADwA0sgQAB6QIJjaANYQAJ7oMDp+LsQAfAAUXd0cdUnI9mo+uv6uANp1ALoAlKHhyGAAFsCcAHTOAW4eYF4gyxNrwbNwago0ypRWp66jH8QcAApwYmAjxq8SWIy2FDCNDA3ToKFBQyIdR69wmfQG1TOhShyBgomQX3w3GQE2Q6IA8jIAFYQBBgI4TTiEs5bTQYsFInrLTbbHZOIlgZDlSqQABqj0kKBC3yINx6a2xfOQwH6o2FVXFaklwSCIUkbQghBAEEwENSfNOlykEGefNe5uhB2O6sgS3GPRmLogmslG1tLxUOKgEDA7hAuydtteryAA)\n\n\t```ts\n\tinterface NodeConfig {\n\t\t\tappName: string;\n\t\t\tport: number;\n\t}\n\n\tclass NodeAppBuilder {\n\t\t\tprivate configuration: NodeConfig = {\n\t\t\t\t\tappName: 'NodeApp',\n\t\t\t\t\tport: 3000\n\t\t\t};\n\n\t\t\tprivate updateConfig(key: Key, value: NodeConfig[Key]) {\n\t\t\t\t\tthis.configuration[key] = value;\n\t\t\t}\n\n\t\t\tconfig(config: Partial) {\n\t\t\t\t\ttype NodeConfigKey = keyof NodeConfig;\n\n\t\t\t\t\tfor (const key of Object.keys(config) as NodeConfigKey[]) {\n\t\t\t\t\t\t\tconst updateValue = config[key];\n\n\t\t\t\t\t\t\tif (updateValue === undefined) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthis.updateConfig(key, updateValue);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this;\n\t\t\t}\n\t}\n\n\t// `Partial`` allows us to provide only a part of the\n\t// NodeConfig interface.\n\tnew NodeAppBuilder().config({appName: 'ToDoApp'});\n\t```\n\t
\n\n- [`Required`](https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype) - Make all properties in `T` required.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/AQ4SwOwFwUwJwGYEMDGNgGED21VQGJZwC2wA3gFCjXAzFJgA2A-AFzADOUckA5gNxUaIYjA4ckvGG07c+g6gF8KQkAgCuEFFDA5O6gEbEwUbLm2ESwABQIixACJIoSdgCUYAR3Vg4MACYAPGYuFvYAfACU5Ko0APRxwADKMBD+wFAAFuh2Vv7OSBlYGdmc8ABu8LHKsRyGxqY4oQT21pTCIHQMjOwA5DAAHgACxAAOjDAAdChYxL0ANLHUouKSMH0AEmAAhJhY6ozpAJ77GTCMjMCiV0ToSAb7UJPPC9WRgrEJwAAqR6MwSRQPFGUFocDgRHYxnEfGAowh-zgUCOwF6KwkUl6tXqJhCeEsxDaS1AXSYfUGI3GUxmc0WSneQA)\n\n\t```ts\n\tinterface ContactForm {\n\t\t\temail?: string;\n\t\t\tmessage?: string;\n\t}\n\n\tfunction submitContactForm(formData: Required) {\n\t\t\t// Send the form data to the server.\n\t}\n\n\tsubmitContactForm({\n\t\t\temail: 'ex@mple.com',\n\t\t\tmessage: 'Hi! Could you tell me more about…',\n\t});\n\n\t// TypeScript error: missing property 'message'\n\tsubmitContactForm({\n\t\t\temail: 'ex@mple.com',\n\t});\n\t```\n\t
\n\n- [`Readonly`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype) - Make all properties in `T` readonly.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/AQ4UwOwVwW2AZA9gc3mAbmANsA3gKFCOAHkAzMgGkOJABEwAjKZa2kAUQCcvEu32AMQCGAF2FYBIAL4BufDRABLCKLBcywgMZgEKZOoDCiCGSXI8i4hGEwwALmABnUVxXJ57YFgzZHSVF8sT1BpBSItLGEnJz1kAy5LLy0TM2RHACUwYQATEywATwAeAITjU3MAPnkrCJMXLigtUT4AClxgGztKbyDgaX99I1TzAEokr1BRAAslJwA6FIqLAF48TtswHp9MHDla9hJGACswZvmyLjAwAC8wVpm5xZHkUZDaMKIwqyWXYCW0oN4sNlsA1h0ug5gAByACyBQAggAHJHQ7ZBIFoXbzBjMCz7OoQP5YIaJNYQMAAdziCVaALGNSIAHomcAACoFJFgADKWjcSNEwG4vC4ji0wggEEQguiTnMEGALWAV1yAFp8gVgEjeFyuKICvMrCTgVxnst5jtsGC4ljsPNhXxGaAWcAAOq6YRXYDCRg+RWIcA5JSC+kWdCepQ+v3RYCU3RInzRMCGwlpC19NYBW1Ye08R1AA)\n\n\t```ts\n\tenum LogLevel {\n\t\t\tOff,\n\t\t\tDebug,\n\t\t\tError,\n\t\t\tFatal\n\t};\n\n\tinterface LoggerConfig {\n\t\t\tname: string;\n\t\t\tlevel: LogLevel;\n\t}\n\n\tclass Logger {\n\t\t\tconfig: Readonly;\n\n\t\t\tconstructor({name, level}: LoggerConfig) {\n\t\t\t\t\tthis.config = {name, level};\n\t\t\t\t\tObject.freeze(this.config);\n\t\t\t}\n\t}\n\n\tconst config: LoggerConfig = {\n\t\tname: 'MyApp',\n\t\tlevel: LogLevel.Debug\n\t};\n\n\tconst logger = new Logger(config);\n\n\t// TypeScript Error: cannot assign to read-only property.\n\tlogger.config.level = LogLevel.Error;\n\n\t// We are able to edit config variable as we please.\n\tconfig.level = LogLevel.Error;\n\t```\n\t
\n\n- [`Pick`](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys) - From `T`, pick a set of properties whose keys are in the union `K`.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/AQ4SwOwFwUwJwGYEMDGNgEE5TCgNugN4BQoZwOUBAXMAM5RyQDmA3KeSFABYCuAtgCMISMHloMmENh04oA9tBjQJjFuzIBfYrOAB6PcADCcGElh1gEGAHcKATwAO6ebyjB5CTNlwFwSxFR0BX5HeToYABNgBDh5fm8cfBg6AHIKG3ldA2BHOOcfFNpUygJ0pAhokr4hETFUgDpswywkggAFUwA3MFtgAF5gQgowKhhVKTYKGuFRcXo1aVZgbTIoJ3RW3xhOmB6+wfbcAGsAHi3kgBpgEtGy4AAfG54BWfqAPnZm4AAlZUj4MAkMA8GAGB4vEgfMlLLw6CwPBA8PYRmMgZVgAC6CgmI4cIommQELwICh8RBgKZKvALh1ur0bHQABR5PYMui0Wk7em2ADaAF0AJS0AASABUALIAGQAogR+Mp3CROCAFBBwVC2ikBpj5CgBIqGjizLA5TAFdAmalImAuqlBRoVQh5HBgEy1eDWfs7J5cjzGYKhroVfpDEhHM4MV6GRR5NN0JrtnRg6BVirTFBeHAKYmYY6QNpdB73LmCJZBlSAXAubtvczeSmQMNSuMbmKNgBlHFgPEUNwusBIPAAQlS1xetTmxT0SDoESgdD0C4aACtHMwxytLrohawgA)\n\n\t```ts\n\tinterface Article {\n\t\t\ttitle: string;\n\t\t\tthumbnail: string;\n\t\t\tcontent: string;\n\t}\n\n\t// Creates new type out of the `Article` interface composed\n\t// from the Articles' two properties: `title` and `thumbnail`.\n\t// `ArticlePreview = {title: string; thumbnail: string}`\n\ttype ArticlePreview = Pick;\n\n\t// Render a list of articles using only title and description.\n\tfunction renderArticlePreviews(previews: ArticlePreview[]): HTMLElement {\n\t\t\tconst articles = document.createElement('div');\n\n\t\t\tfor (const preview of previews) {\n\t\t\t\t\t// Append preview to the articles.\n\t\t\t}\n\n\t\t\treturn articles;\n\t}\n\n\tconst articles = renderArticlePreviews([\n\t\t\t{\n\t\t\t\ttitle: 'TypeScript tutorial!',\n\t\t\t\tthumbnail: '/assets/ts.jpg'\n\t\t\t}\n\t]);\n\t```\n\t
\n\n- [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type) - Construct a type with a set of properties `K` of type `T`.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/AQ4ejYAUHsGcCWAXBMB2dgwGbAKYC2ADgDYwCeeemCaWArgE7ADGMxAhmuQHQBQoYEnJE8wALKEARnkaxEKdMAC8wAOS0kstGuAAfdQBM8ANzxlRjXQbVaWACwC0JPB0NqA3HwGgIwAJJoWozYHCxixnAsjAhStADmwESMMJYo1Fi4HMCIaPEu+MRklHj8gpqyoeHAAKJFFFTAAN4+giDYCIxwSAByHAR4AFw5SDF5Xm2gJBzdfQPD3WPxE5PAlBxdAPLYNQAelgh4aOHDaPQEMowrIAC+3oJ+AMKMrlrAXFhSAFZ4LEhC9g4-0BmA4JBISXgiCkBQABpILrJ5MhUGhYcATGD6Bk4Hh-jNgABrPDkOBlXyQAAq9ngYmJpOAAHcEOCRjAXqwYODfoo6DhakUSph+Uh7GI4P0xER4Cj0OSQGwMP8tP1hgAlX7swwAHgRl2RvIANALSA08ABtAC6AD4VM1Wm0Kow0MMrYaHYJjGYLLJXZb3at1HYnC43Go-QHQDcvA6-JsmEJXARgCDgMYWAhjIYhDAU+YiMAAFIwex0ZmilMITCGF79TLAGRsAgJYAAZRwSEZGzEABFTOZUrJ5Yn+jwnWgeER6HB7AAKJrADpdXqS4ZqYultTG6azVfqHswPBbtauLY7fayQ7HIbAAAMwBuAEoYw9IBq2Ixs9h2eFMOQYPQObALQKJgggABeYhghCIpikkKRpOQRIknAsZUiIeCttECBEP8NSMCkjDDAARMGziuIYxHwYOjDCMBmDNnAuTxA6irdCOBB1Lh5Dqpqn66tISIykawBnOCtqqC0gbjqc9DgpGkxegOliyfJDrRkAA)\n\n\t```ts\n\t// Positions of employees in our company.\n\ttype MemberPosition = 'intern' | 'developer' | 'tech-lead';\n\n\t// Interface describing properties of a single employee.\n\tinterface Employee {\n\t\t\tfirstName: string;\n\t\t\tlastName: string;\n\t\t\tyearsOfExperience: number;\n\t}\n\n\t// Create an object that has all possible `MemberPosition` values set as keys.\n\t// Those keys will store a collection of Employees of the same position.\n\tconst team: Record = {\n\t\t\tintern: [],\n\t\t\tdeveloper: [],\n\t\t\t'tech-lead': [],\n\t};\n\n\t// Our team has decided to help John with his dream of becoming Software Developer.\n\tteam.intern.push({\n\t\tfirstName: 'John',\n\t\tlastName: 'Doe',\n\t\tyearsOfExperience: 0\n\t});\n\n\t// `Record` forces you to initialize all of the property keys.\n\t// TypeScript Error: \"tech-lead\" property is missing\n\tconst teamEmpty: Record = {\n\t\t\tintern: null,\n\t\t\tdeveloper: null,\n\t};\n\t```\n\t
\n\n- [`Exclude`](https://www.typescriptlang.org/docs/handbook/utility-types.html#excludetype-excludedunion) - Exclude from `T` those types that are assignable to `U`.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/JYOwLgpgTgZghgYwgAgMrQG7QMIHsQzADmyA3gFDLIAOuUYAXMiAK4A2byAPsgM5hRQJHqwC2AI2gBucgF9y5MAE9qKAEoQAjiwj8AEnBAATNtGQBeZAAooWphu26wAGmS3e93bRC8IASgsAPmRDJRlyAHoI5ABRAA8ENhYjFFYOZGVVZBgoXFFkAAM0zh5+QRBhZhYJaAKAOkjogEkQZAQ4X2QAdwALCFbaemRgXmQtFjhOMFwq9K6ULuB0lk6U+HYwZAxJnQaYFhAEMGB8ZCIIMAAFOjAANR2IK0HGWISklIAedCgsKDwCYgAbQA5M9gQBdVzFQJ+JhiSRQMiUYYwayZCC4VHPCzmSzAspCYEBWxgFhQAZwKC+FpgJ43VwARgADH4ZFQSWSBjcZPJyPtDsdTvxKWBvr8rD1DCZoJ5HPopaYoK4EPhCEQmGKcKriLCtrhgEYkVQVT5Nr4fmZLLZtMBbFZgT0wGBqES6ghbHBIJqoBKFdBWQpjfh+DQbhY2tqiHVsbjLMVkAB+ZAAZiZaeQTHOVxu9ySjxNaujNwDVHNvzqbBGkBAdPoAfkQA)\n\n\t```ts\n\tinterface ServerConfig {\n\t\tport: null | string | number;\n\t}\n\n\ttype RequestHandler = (request: Request, response: Response) => void;\n\n\t// Exclude `null` type from `null | string | number`.\n\t// In case the port is equal to `null`, we will use default value.\n\tfunction getPortValue(port: Exclude): number {\n\t\tif (typeof port === 'string') {\n\t\t\treturn parseInt(port, 10);\n\t\t}\n\n\t\treturn port;\n\t}\n\n\tfunction startServer(handler: RequestHandler, config: ServerConfig): void {\n\t\tconst server = require('http').createServer(handler);\n\n\t\tconst port = config.port === null ? 3000 : getPortValue(config.port);\n\t\tserver.listen(port);\n\t}\n\t```\n\t
\n\n- [`Extract`](https://www.typescriptlang.org/docs/handbook/utility-types.html#extracttype-union) - Extract from `T` those types that are assignable to `U`.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXzSwEdkQBJYACgEoAueVZAWwCMQYBuAKDDwGcM8MgBF4AXngBlAJ6scESgHIRi6ty5ZUGdoihgEABXZ888AN5d48ANoiAuvUat23K6ihMQ9ATE0BzV3goPy8GZjZOLgBfLi4Aejj4AEEICBwAdz54MAALKFQQ+BxEeAAHY1NgKAwoIKy0grr4DByEUpgccpgMaXgAaxBerCzi+B9-ZulygDouFHRsU1z8kKMYE1RhaqgAHkt4AHkWACt4EAAPbVRgLLWNgBp9gGlBs8uQa6yAUUuYPQwdgNpKM7nh7mMML4CgA+R5WABqUAgpDeVxuhxO1he0jsXGh8EoOBO9COx3BQPo2PBADckaR6IjkSA6PBqTgsMBzPsicdrEC7OJWXSQNwYvFEgAVTS9JLXODpeDpKBZFg4GCoWa8VACIJykAKiQWKy2YQOAioYikCg0OEMDyhRSy4DyxS24KhAAMjyi6gS8AAwjh5OD0iBFHAkJoEOksC1mnkMJq8gUQKDNttKPlnfrwYp3J5XfBHXqoKpfYkAOI4ansTxaeDADmoRSCCBYAbxhC6TDx6rwYHIRX5bScjA4bLJwoDmDwDkfbA9JMrVMVdM1TN69LgkTgwgkchUahqIA)\n\n\t```ts\n\tdeclare function uniqueId(): number;\n\n\tconst ID = Symbol('ID');\n\n\tinterface Person {\n\t\t[ID]: number;\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\t// Allows changing the person data as long as the property key is of string type.\n\tfunction changePersonData<\n\t\tObj extends Person,\n\t\tKey extends Extract,\n\t\tValue extends Obj[Key]\n\t> (obj: Obj, key: Key, value: Value): void {\n\t\tobj[key] = value;\n\t}\n\n\t// Tiny Andrew was born.\n\tconst andrew = {\n\t\t[ID]: uniqueId(),\n\t\tname: 'Andrew',\n\t\tage: 0,\n\t};\n\n\t// Cool, we're fine with that.\n\tchangePersonData(andrew, 'name', 'Pony');\n\n\t// Goverment didn't like the fact that you wanted to change your identity.\n\tchangePersonData(andrew, ID, uniqueId());\n\t```\n\t
\n\n- [`NonNullable`](https://www.typescriptlang.org/docs/handbook/utility-types.html#nonnullabletype) - Exclude `null` and `undefined` from `T`.\n\t
\n\t\n\t\t\tExample\n\t\n\tWorks with strictNullChecks set to true.\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/C4TwDgpgBACg9gJ2AOQK4FsBGEFQLxQDOwCAlgHYDmUAPlORtrnQwDasDcAUFwPQBU-WAEMkUOADMowqAGNWwwoSgATCBIqlgpOOSjAAFsOBRSy1IQgr9cKJlSlW1mZYQA3HFH68u8xcoBlHA8EACEHJ08Aby4oKDBUTFZSWXjEFEYcAEIALihkXTR2YSSIAB54JDQsHAA+blj4xOTUsHSACkMzPKD3HHDHNQQAGjSkPMqMmoQASh7g-oihqBi4uNIpdraxPAI2VhmVxrX9AzMAOm2ppnwoAA4ABifuE4BfKAhWSyOTuK7CS7pao3AhXF5rV48E4ICDAVAIPT-cGQyG+XTEIgLMJLTx7CAAdygvRCA0iCHaMwarhJOIQjUBSHaACJHk8mYdeLwxtdcVAAOSsh58+lXdr7Dlcq7A3n3J4PEUdADMcspUE53OluAIUGVTx46oAKuAIAFZGQwCYAKIIBCILjUxaDHAMnla+iodjcIA)\n\n\t```ts\n\ttype PortNumber = string | number | null;\n\n\t/** Part of a class definition that is used to build a server */\n\tclass ServerBuilder {\n\t\t\tportNumber!: NonNullable;\n\n\t\t\tport(this: ServerBuilder, port: PortNumber): ServerBuilder {\n\t\t\t\t\tif (port == null) {\n\t\t\t\t\t\t\tthis.portNumber = 8000;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.portNumber = port;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this;\n\t\t\t}\n\t}\n\n\tconst serverBuilder = new ServerBuilder();\n\n\tserverBuilder\n\t\t\t.port('8000') // portNumber = '8000'\n\t\t\t.port(null) // portNumber = 8000\n\t\t\t.port(3000); // portNumber = 3000\n\n\t// TypeScript error\n\tserverBuilder.portNumber = null;\n\t```\n\t
\n\n- [`Parameters`](https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype) - Obtain the parameters of a function type in a tuple.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/GYVwdgxgLglg9mABAZwBYmMANgUwBQxgAOIUAXIgIZgCeA2gLoCUFAbnDACaIDeAUIkQB6IYgCypSlBxUATrMo1ECsJzgBbLEoipqAc0J7EMKMgDkiHLnU4wp46pwAPHMgB0fAL58+oSLARECEosLAA5ABUYG2QAHgAxJGdpVWREPDdMylk9ZApqemZEAF4APipacrw-CApEgBogkKwAYThwckQwEHUAIxxZJl4BYVEImiIZKF0oZRwiWVdbeygJmThgOYgcGFYcbhqApCJsyhtpWXcR1cnEePBoeDAABVPzgbTixFeFd8uEsClADcIxGiygIFkSEOT3SmTc2VydQeRx+ZxwF2QQ34gkEwDgsnSuFmMBKiAADEDjIhYk1Qm0OlSYABqZnYka4xA1DJZHJYkGc7yCbyeRA+CAIZCzNAYbA4CIAdxg2zJwVCkWirjwMswuEaACYmCCgA)\n\n\t```ts\n\tfunction shuffle(input: any[]): void {\n\t\t// Mutate array randomly changing its' elements indexes.\n\t}\n\n\tfunction callNTimes any> (func: Fn, callCount: number) {\n\t\t// Type that represents the type of the received function parameters.\n\t\ttype FunctionParameters = Parameters;\n\n\t\treturn function (...args: FunctionParameters) {\n\t\t\tfor (let i = 0; i < callCount; i++) {\n\t\t\t\tfunc(...args);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst shuffleTwice = callNTimes(shuffle, 2);\n\t```\n\t
\n\n- [`ConstructorParameters`](https://www.typescriptlang.org/docs/handbook/utility-types.html#constructorparameterstype) - Obtain the parameters of a constructor function type in a tuple.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/MYGwhgzhAECCBOAXAlqApgWQPYBM0mgG8AoaaFRENALmgkXmQDsBzAblOmCycTV4D8teo1YdO3JiICuwRFngAKClWENmLAJRFOZRAAtkEAHQq00ALzlklNBzIBfYk+KhIMAJJTEYJsDQAwmDA+mgAPAAq0GgAHnxMODCKTGgA7tCKxllg8CwQtL4AngDaALraFgB80EWa1SRkAA6MAG5gfNAB4FABPDJyCrQR9tDNyG0dwMGhtBhgjWEiGgA00F70vv4RhY3hEZXVVinpc42KmuJkkv3y8Bly8EPaDWTkhiZd7r3e8LK3llwGCMXGQWGhEOsfH5zJlsrl8p0+gw-goAAo5MAAW3BaHgEEilU0tEhmzQ212BJ0ry4SOg+kg+gBBiMximIGA0nAfAQLGk2N4EAAEgzYcYcnkLsRdDTvNEYkYUKwSdCme9WdM0MYwYhFPSIPpJdTkAAzDKxBUaZX+aAAQgsVmkCTQxuYaBw2ng4Ok8CYcotSu8pMur09iG9vuObxZnx6SN+AyUWTF8MN0CcZE4Ywm5jZHK5aB5fP4iCFIqT4oRRTKRLo6lYVNeAHpG50wOzOe1zHr9NLQ+HoABybsD4HOKXXRA1JCoKhBELmI5pNaB6Fz0KKBAodDYPAgSUTmqYsAALx4m5nC6nW9nGq14KtaEUA9gR9PvuNCjQ9BgACNvcwNBtAcLiAA)\n\n\t```ts\n\tclass ArticleModel {\n\t\ttitle: string;\n\t\tcontent?: string;\n\n\t\tconstructor(title: string) {\n\t\t\tthis.title = title;\n\t\t}\n\t}\n\n\tclass InstanceCache any)> {\n\t\tprivate ClassConstructor: T;\n\t\tprivate cache: Map> = new Map();\n\n\t\tconstructor (ctr: T) {\n\t\t\tthis.ClassConstructor = ctr;\n\t\t}\n\n\t\tgetInstance (...args: ConstructorParameters): InstanceType {\n\t\t\tconst hash = this.calculateArgumentsHash(...args);\n\n\t\t\tconst existingInstance = this.cache.get(hash);\n\t\t\tif (existingInstance !== undefined) {\n\t\t\t\treturn existingInstance;\n\t\t\t}\n\n\t\t\treturn new this.ClassConstructor(...args);\n\t\t}\n\n\t\tprivate calculateArgumentsHash(...args: any[]): string {\n\t\t\t// Calculate hash.\n\t\t\treturn 'hash';\n\t\t}\n\t}\n\n\tconst articleCache = new InstanceCache(ArticleModel);\n\tconst amazonArticle = articleCache.getInstance('Amazon forests burining!');\n\t```\n\t
\n\n- [`ReturnType`](https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypetype) - Obtain the return type of a function type.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/MYGwhgzhAECSAmICmBlJAnAbgS2E6A3gFDTTwD2AcuQC4AW2AdgOYAUAlAFzSbnbyEAvkWFFQkGJSQB3GMVI1sNZNwg10TZgG4S0YOUY0kh1es07d+xmvQBXYDXLpWi5UlMaWAGj0GjJ6BtNdkJdBQYIADpXZGgAXmgYpB1ScOwoq38aeN9DYxoU6GFRKzVoJjUwRjwAYXJbPPRuAFkwAAcAHgAxBodsAx9GWwBbACMMAD4cxhloVraOCyYjdAAzMDxoOut1e0d0UNIZ6WhWSPOwdGYIbiqATwBtAF0uaHudUQB6ACpv6ABpJBINqJdAbADW0Do5BOw3u5R2VTwMHIq2gAANtjZ0bkbHsnFCwJh8ONjHp0EgwEZ4JFoN9PkRVr1FAZoMwkDRYIjqkgOrosepoEgAB7+eAwAV2BxOLy6ACCVxgIrFEoMeOl6AACpcwMMORgIB1JRMiBNWKVdhruJKfOdIpdrtwFddXlzKjyACp3Nq842HaDIbL6BrZBIVGhIpB1EMYSLsmjmtWW-YhAA+qegAAYLKQLQj3ZsEsdccmnGcLor2Dn8xGedHGpEIBzEzspfsfMHDNAANTQACMVaIljV5GQkRA5DYmIpVKQAgAJARO9le33BDXIyi0YuLW2nJFGLqkOvxFB0YPdBSaLZ0IwNzyPkO8-xkGgsLh8Al427a3hWAhXwwHA8EHT5PmgAB1bAQBAANJ24adKWpft72RaBUTgRBUCAj89HAM8xCTaBjggABRQx0DuHJv25P9dCkWRZVIAAiBjoFImpmjlFBgA0NpsjadByDacgIDAEAIAAQmYpjoGYgAZSBsmGPw6DtZiiFA8CoJguDmAQmoZ2QvtUKQLdoAYmBTwgdEiCAA)\n\n\t```ts\n\t/** Provides every element of the iterable `iter` into the `callback` function and stores the results in an array. */\n\tfunction mapIter<\n\t\t\tElem,\n\t\t\tFunc extends (elem: Elem) => any,\n\t\t\tRet extends ReturnType\n\t>(iter: Iterable, callback: Func): Ret[] {\n\t\t\tconst mapped: Ret[] = [];\n\n\t\t\tfor (const elem of iter) {\n\t\t\t\t\tmapped.push(callback(elem));\n\t\t\t}\n\n\t\t\treturn mapped;\n\t}\n\n\tconst setObject: Set = new Set();\n\tconst mapObject: Map = new Map();\n\n\tmapIter(setObject, (value: string) => value.indexOf('Foo')); // number[]\n\n\tmapIter(mapObject, ([key, value]: [number, string]) => {\n\t\t\treturn key % 2 === 0 ? value : 'Odd';\n\t}); // string[]\n\t```\n\t
\n\n- [`InstanceType`](https://www.typescriptlang.org/docs/handbook/utility-types.html#instancetypetype) - Obtain the instance type of a constructor function type.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/MYGwhgzhAECSAmICmBlJAnAbgS2E6A3gFDTTwD2AcuQC4AW2AdgOYAUAlAFzSbnbyEAvkWFFQkGJSQB3GMVI1sNZNwg10TZgG4S0YOUY0kh1es07d+xmvQBXYDXLpWi5UlMaWAGj0GjJ6BtNdkJdBQYIADpXZGgAXmgYpB1ScOwoq38aeN9DYxoU6GFRKzVoJjUwRjwAYXJbPPRuAFkwAAcAHgAxBodsAx9GWwBbACMMAD4cxhloVraOCyYjdAAzMDxoOut1e0d0UNIZ6WhWSPOwdGYIbiqATwBtAF0uaHudUQB6ACpv6ABpJBINqJdAbADW0Do5BOw3u5R2VTwMHIq2gAANtjZ0bkbHsnFCwJh8ONjHp0EgwEZ4JFoN9PkRVr1FAZoMwkDRYIjqkgOrosepoEgAB7+eAwAV2BxOLy6ACCVxgIrFEoMeOl6AACpcwMMORgIB1JRMiBNWKVdhruJKfOdIpdrtwFddXlzKjyACp3Nq842HaDIbL6BrZBIVGhIpB1EMYSLsmjmtWW-YhAA+qegAAYLKQLQj3ZsEsdccmnGcLor2Dn8xGedHGpEIBzEzspfsfMHDNAANTQACMVaIljV5GQkRA5DYmIpVKQAgAJARO9le33BDXIyi0YuLW2nJFGLqkOvxFB0YPdBSaLZ0IwNzyPkO8-xkGgsLh8Al427a3hWAhXwwHA8EHT5PmgAB1bAQBAANJ24adKWpft72RaBUTgRBUCAj89HAM8xCTaBjggABRQx0DuHJv25P9dCkWRZVIAAiBjoFImpmjlFBgA0NpsjadByDacgIDAEAIAAQmYpjoGYgAZSBsmGPw6DtZiiFA8CoJguDmAQmoZ2QvtUKQLdoAYmBTwgdEiCAA)\n\n\t```ts\n\tclass IdleService {\n\t\t\tdoNothing (): void {}\n\t}\n\n\tclass News {\n\t\t\ttitle: string;\n\t\t\tcontent: string;\n\n\t\t\tconstructor(title: string, content: string) {\n\t\t\t\t\tthis.title = title;\n\t\t\t\t\tthis.content = content;\n\t\t\t}\n\t}\n\n\tconst instanceCounter: Map = new Map();\n\n\tinterface Constructor {\n\t\t\tnew(...args: any[]): any;\n\t}\n\n\t// Keep track how many instances of `Constr` constructor have been created.\n\tfunction getInstance<\n\t\t\tConstr extends Constructor,\n\t\t\tArgs extends ConstructorParameters\n\t>(constructor: Constr, ...args: Args): InstanceType {\n\t\t\tlet count = instanceCounter.get(constructor) || 0;\n\n\t\t\tconst instance = new constructor(...args);\n\n\t\t\tinstanceCounter.set(constructor, count + 1);\n\n\t\t\tconsole.log(`Created ${count + 1} instances of ${Constr.name} class`);\n\n\t\t\treturn instance;\n\t}\n\n\n\tconst idleService = getInstance(IdleService);\n\t// Will log: `Created 1 instances of IdleService class`\n\tconst newsEntry = getInstance(News, 'New ECMAScript proposals!', 'Last month...');\n\t// Will log: `Created 1 instances of News class`\n\t```\n\t
\n\n- [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys) - Constructs a type by picking all properties from T and then removing K.\n\t
\n\t\n\t\t\tExample\n\t\n\n\t[Playground](https://typescript-play.js.org/?target=6#code/JYOwLgpgTgZghgYwgAgIImAWzgG2QbwChlks4BzCAVShwC5kBnMKUcgbmKYAcIFgIjBs1YgOXMpSFMWbANoBdTiW5woFddwAW0kfKWEAvoUIB6U8gDCUCHEiNkICAHdkYAJ69kz4GC3JcPG4oAHteKDABBxCYNAxsPFBIWEQUCAAPJG4wZABySUFcgJAAEzMLXNV1ck0dIuCw6EjBADpy5AB1FAQ4EGQAV0YUP2AHDy8wEOQbUugmBLwtEIA3OcmQnEjuZBgQqE7gAGtgZAhwKHdkHFGwNvGUdDIcAGUliIBJEF3kAF5kAHlML4ADyPBIAGjyBUYRQAPnkqho4NoYQA+TiEGD9EAISIhPozErQMG4AASK2gn2+AApek9pCSXm8wFSQooAJQMUkAFQAsgAZACiOAgmDOOSIJAQ+OYyGl4DgoDmf2QJRCCH6YvALQQNjsEGFovF1NyJWAy1y7OUyHMyE+yRAuFImG4Iq1YDswHxbRINjA-SgfXlHqVUE4xiAA)\n\n\t```ts\n\tinterface Animal {\n\t\t\timageUrl: string;\n\t\t\tspecies: string;\n\t\t\timages: string[];\n\t\t\tparagraphs: string[];\n\t}\n\n\t// Creates new type with all properties of the `Animal` interface\n\t// except 'images' and 'paragraphs' properties. We can use this\n\t// type to render small hover tooltip for a wiki entry list.\n\ttype AnimalShortInfo = Omit;\n\n\tfunction renderAnimalHoverInfo (animals: AnimalShortInfo[]): HTMLElement {\n\t\t\tconst container = document.createElement('div');\n\t\t\t// Internal implementation.\n\t\t\treturn container;\n\t}\n\t```\n\t
\n\n- [`Uppercase`](https://www.typescriptlang.org/docs/handbook/utility-types.html#uppercasestringtype) - Transforms every character in a string into uppercase.\n\t
\n\t\n\t\tExample\n\t\n\n\t```ts\n\ttype T = Uppercase<'hello'>; // 'HELLO'\n\n\ttype T2 = Uppercase<'foo' | 'bar'>; // 'FOO' | 'BAR'\n\n\ttype T3 = Uppercase<`aB${S}`>;\n\ttype T4 = T3<'xYz'>; // 'ABXYZ'\n\n\ttype T5 = Uppercase; // string\n\ttype T6 = Uppercase; // any\n\ttype T7 = Uppercase; // never\n\ttype T8 = Uppercase<42>; // Error, type 'number' does not satisfy the constraint 'string'\n\t```\n\t
\n\n- [`Lowercase`](https://www.typescriptlang.org/docs/handbook/utility-types.html#lowercasestringtype) - Transforms every character in a string into lowercase.\n\t
\n\t\n\t\tExample\n\t\n\n\t```ts\n\ttype T = Lowercase<'HELLO'>; // 'hello'\n\n\ttype T2 = Lowercase<'FOO' | 'BAR'>; // 'foo' | 'bar'\n\n\ttype T3 = Lowercase<`aB${S}`>;\n\ttype T4 = T3<'xYz'>; // 'abxyz'\n\n\ttype T5 = Lowercase; // string\n\ttype T6 = Lowercase; // any\n\ttype T7 = Lowercase; // never\n\ttype T8 = Lowercase<42>; // Error, type 'number' does not satisfy the constraint 'string'\n\t```\n\t
\n\n- [`Capitalize`](https://www.typescriptlang.org/docs/handbook/utility-types.html#capitalizestringtype) - Transforms the first character in a string into uppercase.\n\t
\n\t\n\t\tExample\n\t\n\n\t```ts\n\ttype T = Capitalize<'hello'>; // 'Hello'\n\n\ttype T2 = Capitalize<'foo' | 'bar'>; // 'Foo' | 'Bar'\n\n\ttype T3 = Capitalize<`aB${S}`>;\n\ttype T4 = T3<'xYz'>; // 'ABxYz'\n\n\ttype T5 = Capitalize; // string\n\ttype T6 = Capitalize; // any\n\ttype T7 = Capitalize; // never\n\ttype T8 = Capitalize<42>; // Error, type 'number' does not satisfy the constraint 'string'\n\t```\n\t
\n\n- [`Uncapitalize`](https://www.typescriptlang.org/docs/handbook/utility-types.html#uncapitalizestringtype) - Transforms the first character in a string into lowercase.\n\t
\n\t\n\t\tExample\n\t\n\n\t```ts\n\ttype T = Uncapitalize<'Hello'>; // 'hello'\n\n\ttype T2 = Uncapitalize<'Foo' | 'Bar'>; // 'foo' | 'bar'\n\n\ttype T3 = Uncapitalize<`AB${S}`>;\n\ttype T4 = T3<'xYz'>; // 'aBxYz'\n\n\ttype T5 = Uncapitalize; // string\n\ttype T6 = Uncapitalize; // any\n\ttype T7 = Uncapitalize; // never\n\ttype T8 = Uncapitalize<42>; // Error, type 'number' does not satisfy the constraint 'string'\n\t```\n\t
\n\nYou can find some examples in the [TypeScript docs](https://www.typescriptlang.org/docs/handbook/utility-types.html).\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [Jarek Radosz](https://github.com/CvX)\n- [Dimitri Benin](https://github.com/BendingBender)\n- [Pelle Wessman](https://github.com/voxpelli)\n\n## License\n\nSPDX-License-Identifier: (MIT OR CC0-1.0)\n\n---\n\n
\n\t\n\t\tGet professional support for this package with a Tidelift subscription\n\t\n\t
\n\t\n\t\tTidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.\n\t
\n
\n" }, "artifacts": [], "remote": { "resolved": "https://registry.yarnpkg.com/type-fest/-/type-fest-2.19.0.tgz#88068015bb33036a598b952e55e9311a60fd3a9b", "type": "tarball", "reference": "https://registry.yarnpkg.com/type-fest/-/type-fest-2.19.0.tgz", "hash": "88068015bb33036a598b952e55e9311a60fd3a9b", "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", "registry": "npm", "packageName": "type-fest", "cacheIntegrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA== sha1-iAaAFbszA2pZi5UuVekxGmD9Ops=" }, "registry": "npm", "hash": "88068015bb33036a598b952e55e9311a60fd3a9b" }