@greenymcgee/utility-types
v0.1.1
Published
These are a set of utility types that I use in my projects.
Readme
Utility Types
These are a set of utility types that I use in my projects.
Installation
npm
npm install -D @greenymcgee/utility-typespnpm
pnpm add -D @greenymcgee/utility-typesUsage
Add this to your project's tsconfig.json file.
"compilerOptions": {
"types": ["@greenymcgee/utility-types"]
}Types
FirstParameterOf
Used to get the first parameter of a function.
type YourType = FirstParameterOf<typeof yourFunction>SecondParameterOf
Used to get the second parameter of a function.
type YourType = SecondParameterOf<typeof yourFunction>ThirdParameterOf
Used to get the third parameter of a function.
type YourType = ThirdParameterOf<typeof yourFunction>PropsOf
Used to get the props of a component.
type YourProps = PropsOf<typeof YourComponent>OneOf
Used to get the first element of an array. Very useful if you have an array of typed objects, but don't need a type for the objects themselves.
type YourType = OneOf<typeof yourArray>