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-sknext-beta.9

build/cjs/index.js

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 @@

26

package.json
{
"name": "@shopify/useful-types",
"version": "2.1.5",
"version": "2.2.0-sknext-beta.9",
"license": "MIT",
"description": "A few handy TypeScript types",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"scripts": {

@@ -30,5 +30,19 @@ "build": "tsc --p tsconfig.json"

"files": [
"dist/*",
"!tsconfig.tsbuildinfo"
]
"build/*",
"!tsconfig.tsbuildinfo",
"index.js",
"index.mjs",
"index.esnext",
"index.d.ts"
],
"module": "index.mjs",
"esnext": "index.esnext",
"exports": {
"./": "./",
"./index": {
"import": "./index.mjs",
"require": "./index.js",
"esnext": "./index.esnext"
}
}
}

@@ -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 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc