mirror of
https://github.com/stCarolas/setup-maven.git
synced 2024-11-13 21:38:04 +00:00
.. | ||
source | ||
index.d.ts | ||
license | ||
package.json | ||
readme.md |
Many of the types here should have been built-in. You can help by suggesting some of them to the TypeScript project.
Either add this package as a dependency or copy-paste the needed types. No credit required. 👌
PR welcome for additional commonly needed types and docs improvements. Read the contributing guidelines first.
Install
$ npm install type-fest
Requires TypeScript >=3.2
Usage
import {Except} from 'type-fest';
type Foo = {
unicorn: string;
rainbow: boolean;
};
type FooWithoutRainbow = Except<Foo, 'rainbow'>;
//=> {unicorn: string}
API
Click the type names for complete docs.
Basic
Primitive
- Matches any primitive value.Class
- Matches aclass
constructor.TypedArray
- Matches any typed array, likeUint8Array
orFloat64Array
.JsonObject
- Matches a JSON object.JsonArray
- Matches a JSON array.JsonValue
- Matches any valid JSON value.ObservableLike
- Matches a value that is like an Observable.
Utilities
Except
- Create a type from an object type without certain keys. This is a stricter version ofOmit
.Mutable
- Convert an object withreadonly
properties into a mutable object. Inverse ofReadonly<T>
.Merge
- Merge two types into a new type. Keys of the second type overrides keys of the first type.MergeExclusive
- Create a type that has mutually exclusive properties.RequireAtLeastOne
- Create a type that requires at least one of the given properties.ReadonlyDeep
- Create a deeply immutable version of aobject
/Map
/Set
/Array
type.LiteralUnion
- 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.Promisable
- Create a type that represents either the value or the value wrapped inPromiseLike
.
Miscellaneous
PackageJson
- Type for npm'spackage.json
file.
Declined types
If we decline a type addition, we will make sure to document the better solution here.
Diff
andSpread
- The PR 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.
Tips
Built-in types
There are many advanced types most users don't know about.
Partial<T>
- Make all properties inT
optional.Required<T>
- Make all properties inT
required.Readonly<T>
- Make all properties inT
readonly.Pick<T, K>
- FromT
, pick a set of properties whose keys are in the unionK
.Record<K, T>
- Construct a type with a set of propertiesK
of typeT
.Exclude<T, U>
- Exclude fromT
those types that are assignable toU
.Extract<T, U>
- Extract fromT
those types that are assignable toU
.NonNullable<T>
- Excludenull
andundefined
fromT
.Parameters<T>
- Obtain the parameters of a function type in a tuple.ConstructorParameters<T>
- Obtain the parameters of a constructor function type in a tuple.ReturnType<T>
– Obtain the return type of a function type.InstanceType<T>
– Obtain the instance type of a constructor function type.
You can find some examples in the TypeScript docs.
Maintainers
License
(MIT OR CC0-1.0)