@gradecam/tsenum
Advanced tools
Comparing version 1.1.0 to 1.2.0
/** | ||
* These are the valid value types to use with the enum; enum must use a string | ||
* indexor but the value can be any of these types: | ||
*/ | ||
declare type ValidEnumTypes = number | string | boolean; | ||
/** | ||
* Use this along with TypeFromEnum to make a "fake" frozen enum which can be | ||
@@ -25,3 +30,3 @@ * used in place of an enum in ways that are mongoose-friendly and much more | ||
[index: string]: U; | ||
}, U extends string>(x1: T1): Readonly<T1>; | ||
}, U extends ValidEnumTypes>(x1: T1): Readonly<T1>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -31,3 +36,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2): Readonly<T1 & T2>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2): Readonly<T1 & T2>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -39,3 +44,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2, x3: T3): Readonly<T1 & T2 & T3>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2, x3: T3): Readonly<T1 & T2 & T3>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -49,3 +54,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2, x3: T3, x4: T4): Readonly<T1 & T2 & T3 & T4>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2, x3: T3, x4: T4): Readonly<T1 & T2 & T3 & T4>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -61,3 +66,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5): Readonly<T1 & T2 & T3 & T4 & T5>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5): Readonly<T1 & T2 & T3 & T4 & T5>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -75,3 +80,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6): Readonly<T1 & T2 & T3 & T4 & T5 & T6>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6): Readonly<T1 & T2 & T3 & T4 & T5 & T6>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -91,3 +96,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -109,3 +114,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8>; | ||
declare function MakeEnum<T1 extends { | ||
@@ -129,3 +134,3 @@ [index: string]: U; | ||
[index: string]: U; | ||
}, U extends string>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9>; | ||
}, U extends ValidEnumTypes>(x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9>; | ||
/** | ||
@@ -132,0 +137,0 @@ * Use this with MakeEnum. See docs for MakeEnum for example |
{ | ||
"name": "@gradecam/tsenum", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Super simple typescript library for string-compatible enums", | ||
@@ -27,2 +27,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"bower": "^1.8.8", | ||
"typescript": "~3.2.2" | ||
@@ -29,0 +30,0 @@ }, |
@@ -81,2 +81,7 @@ | ||
const PrimaryColorList = Object.values(PrimaryColors); // ['red', 'blue', 'green'] | ||
// typeof PrimaryColorList = Array<'red'|'blue'|'green'> | ||
// typeof PrimaryColorList = Array<'red'|'blue'|'green'> | ||
Allowed value types | ||
=================== | ||
Currently you can use any string, number, or boolean as a value |
9722
186
87
2