@types/ink-gradient
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -9,33 +9,33 @@ // Type definitions for ink-gradient 2.0 | ||
// This needs to be updated when TypeScript enhances their support for mutual | ||
// exclusivity in properties. While I am defining the props as being either one with | ||
// name OR one with colors, and the type reflects this on hover, it doesnt throw any lint errors | ||
// when I disobey this type contstraint. | ||
type PropsColor = | ||
| { | ||
name: | ||
| 'cristal' | ||
| 'teen' | ||
| 'mind' | ||
| 'morning' | ||
| 'vice' | ||
| 'passion' | ||
| 'fruit' | ||
| 'instagram' | ||
| 'atlas' | ||
| 'retro' | ||
| 'summer' | ||
| 'pastel' | ||
| 'rainbow'; | ||
} | ||
| { | ||
colors: string[] | object[]; | ||
}; | ||
// exclusivity in properties. This edit I made will now throw errors when | ||
// a user gives both of the mutually exclusive props. | ||
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }; | ||
type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U; | ||
interface PropsName { | ||
name: | ||
| 'cristal' | ||
| 'teen' | ||
| 'mind' | ||
| 'morning' | ||
| 'vice' | ||
| 'passion' | ||
| 'fruit' | ||
| 'instagram' | ||
| 'atlas' | ||
| 'retro' | ||
| 'summer' | ||
| 'pastel' | ||
| 'rainbow'; | ||
} | ||
// note, object[] in this case refers to objects interpretable by tinycolor2 | ||
interface PropsColor { | ||
colors: string[] | object[]; | ||
} | ||
type GradientProps = { | ||
children: React.ReactNode; | ||
} & PropsColor; | ||
type GradientProps = XOR<PropsName, PropsColor> & { children: React.ReactNode }; | ||
declare const Gradient: React.FC<GradientProps>; | ||
export = Gradient; |
{ | ||
"name": "@types/ink-gradient", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "TypeScript definitions for ink-gradient", | ||
@@ -24,4 +24,4 @@ "license": "MIT", | ||
}, | ||
"typesPublisherContentHash": "4c98c6a46fa6d5b97c19b8afd29780b986caf3ff1ba739086394b49be2cc9a5a", | ||
"typesPublisherContentHash": "a473cdf5d1623de3702fd6d34258cfde9db74d803d0c26dac57213d3beeb9d74", | ||
"typeScriptVersion": "3.2" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Tue, 20 Oct 2020 02:36:39 GMT | ||
* Last updated: Sat, 24 Oct 2020 17:21:40 GMT | ||
* Dependencies: [@types/react](https://npmjs.com/package/@types/react) | ||
@@ -14,0 +14,0 @@ * Global values: none |
3653
33