@shopify/useful-types
Advanced tools
Comparing version 1.3.0 to 2.0.0
@@ -8,2 +8,6 @@ # Changelog | ||
## [2.0.0] | ||
- Removed `Props<T>`, see `ComponentProps`, `ComponentPropsWithRef`, and `ComponentPropsWithoutRef` from `react` for a replacement strategy ([#846](https://github.com/Shopify/quilt/pull/846)) | ||
## [1.3.0] | ||
@@ -10,0 +14,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { ComponentType, HTMLAttributes } from 'react'; | ||
export declare type ThenType<T> = T extends Promise<infer U> ? U : T; | ||
@@ -12,3 +11,2 @@ export declare type Arguments<T> = T extends (...args: infer U) => any ? U : never; | ||
}; | ||
export declare type Props<T> = T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : T extends string ? HTMLAttributes<T> : T extends ComponentType<infer Props> ? Props : never; | ||
export declare type IfEmptyObject<Obj, If, Else = never> = keyof Obj extends { | ||
@@ -15,0 +13,0 @@ length: 0; |
{ | ||
"name": "@shopify/useful-types", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -26,3 +26,2 @@ "description": "A few handy TypeScript types", | ||
"dependencies": { | ||
"@types/react": ">=16.4.0", | ||
"tslib": "^1.9.3" | ||
@@ -29,0 +28,0 @@ }, |
@@ -63,19 +63,2 @@ # `@shopify/useful-types` | ||
- `Props<T>`: Extracts the prop type from a React component. This allows you to access property types without having to manually export/ import the type. | ||
```tsx | ||
function MyComponent({name}: {name: string}) { | ||
return <div>Hello, {name}!</div>; | ||
} | ||
class MyOtherComponent extends React.Component<{seconds: number}> { | ||
render() { | ||
return <div>{this.props.seconds} seconds left!</div>; | ||
} | ||
} | ||
type MyComponentProps = Props<typeof MyComponent>; // {name: string} | ||
type MyOtherComponentProps = Props<typeof MyOtherComponent>; // {seconds: number} | ||
``` | ||
- `DeepPartial<T>`: Recusively maps over all properties in a type and transforms them to be optional. Useful when you need to make optional all of the properties (and nested properties) of an existing type. | ||
@@ -82,0 +65,0 @@ |
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
1
6226
33
75
- Removed@types/react@>=16.4.0
- Removed@types/prop-types@15.7.13(transitive)
- Removed@types/react@18.3.11(transitive)
- Removedcsstype@3.1.3(transitive)