@shopify/useful-types
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -8,2 +8,10 @@ # Changelog | ||
## [Unreleased] | ||
## [2.1.0] - 2019-10-30 | ||
### Added | ||
- Added the `NoInfer<T>` type alias. | ||
## [2.0.0] | ||
@@ -10,0 +18,0 @@ |
@@ -26,4 +26,7 @@ export declare type ThenType<T> = T extends Promise<infer U> ? U : T; | ||
}[keyof T]; | ||
export declare type NoInfer<T> = { | ||
[K in keyof T]: T[K]; | ||
} & T; | ||
declare type ReactStatics = 'displayName' | 'getDerivedStateFromProps' | 'getDerivedStateFromErrors' | 'childContextTypes' | 'contextType' | 'contextTypes' | 'getDefaultProps' | 'propTypes'; | ||
export declare type NonReactStatics<T> = Pick<T, Exclude<keyof T, ReactStatics>>; | ||
export {}; |
{ | ||
"name": "@shopify/useful-types", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A few handy TypeScript types", |
@@ -75,1 +75,10 @@ # `@shopify/useful-types` | ||
``` | ||
- `NoInfer<T>`: creates a ["lower priority inference site"](https://github.com/microsoft/TypeScript/issues/14829#issuecomment-320754731), which allows other uses of a generic to take precedence in inference. | ||
```ts | ||
// Here, TypeScript will always use the type of the items in the `items` argument as `T`, and will not consider the type of the `item` argument of `renderItem`. | ||
function render<T>(items: T[], renderItem: (item: NoInfer<T>) => string) { | ||
/* implementation */ | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6823
36
84