Socket
Socket
Sign inDemoInstall

@shopify/useful-types

Package Overview
Dependencies
Maintainers
13
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/useful-types - npm Package Compare versions

Comparing version 2.1.5 to 2.2.0

6

CHANGELOG.md

@@ -8,4 +8,8 @@ # Changelog

<!-- ## [Unreleased] -->
## [2.2.0] - 2019-06-12
### Added
- Added the `ConstructorArguments`, `ConstructorArgumentAtIndex`, and `FirstConstructorArgument` type aliases
## [2.1.4] - 2019-01-27

@@ -12,0 +16,0 @@

@@ -32,3 +32,8 @@ export declare type ThenType<T> = T extends Promise<infer U> ? U : T;

export declare type ExtendedWindow<T> = Window & typeof globalThis & T;
export declare type ConstructorArguments<T> = T extends {
new (...args: infer U): any;
} ? U : never;
export declare type ConstructorArgumentAtIndex<T, I extends keyof ConstructorArguments<T>> = ConstructorArguments<T>[I];
export declare type FirstConstructorArgument<T> = ConstructorArgumentAtIndex<T, 0>;
export {};
//# sourceMappingURL=types.d.ts.map

2

package.json
{
"name": "@shopify/useful-types",
"version": "2.1.5",
"version": "2.2.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "A few handy TypeScript types",

@@ -44,2 +44,26 @@ # `@shopify/useful-types`

- `ConstructorArgumentAtIndex<T, Index>`: Resolves to the type of the argument of the passed class's constructor at the passed index. Useful for cases where you wish to extract the type of arguments without actually exporting the argument types, and is a nice complement to TypeScript’s built-in `ReturnType`.
```tsx
class SomeClass {
constructor(floop: string, doop: number) {
console.log(floop);
}
}
type DoopType = ConstructorArgument<typeof SomeClass, 1>; // number
```
- `FirstConstructorArgument<T>`: Resolves to the type of the first argument to the passed class's constructor. This is shorthand for `ConstructorArgumentAtIndex<T, 0>`.
```ts
class SomeClass {
constructor(floop: string) {
console.log(floop);
}
}
type DoopType = FirstConstructorArgument<typeof SomeClass>; // string
```
- `ArrayElement<T>`: When `T` is an array, resolves to the type contained within the array.

@@ -46,0 +70,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc