@js-bits/enumerate
Advanced tools
Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "@js-bits/enumerate", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Easy to use, Symbol-based enum implementation", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import type { Add, Multiply } from '@js-bits/typedef-utils/math'; | ||
import type { UniqueSymbols } from './unique-symbols'; | ||
@@ -45,11 +46,2 @@ type ToUnion<T extends unknown[]> = T[number]; | ||
// workaround for https://github.com/microsoft/TypeScript/issues/37469 | ||
const UniqueSymbol: unique symbol = Symbol('UniqueSymbol'); | ||
export type SymbolValue<Type extends Converter> = Type extends SymbolConstructor | ||
? typeof UniqueSymbol | ||
: Type extends SymbolConstructor['for'] | ||
? typeof UniqueSymbol | ||
: never; | ||
export type Index<Keys extends string[], Multiplier extends number = 1> = { | ||
@@ -63,2 +55,15 @@ [I in keyof Keys]: [Keys[I], Multiply<I, Multiplier>]; | ||
export type SymbolValue< | ||
Type extends Converter, | ||
Key extends string, | ||
Keys extends string[], | ||
// "Type instantiation is excessively deep and possibly infinite" error | ||
// Workaround https://www.angularfix.com/2022/01/why-am-i-getting-instantiation-is.html | ||
Map extends { [key: string]: keyof UniqueSymbols } = Key extends string ? IndexMap<ToUnion<Index<Keys>>> : never | ||
> = Type extends SymbolConstructor | ||
? UniqueSymbols[Map[Key]] | ||
: Type extends SymbolConstructor['for'] | ||
? UniqueSymbols[Map[Key]] | ||
: never; | ||
export type NumberValue< | ||
@@ -65,0 +70,0 @@ Type extends Converter, |
@@ -36,9 +36,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
// workaround for https://github.com/microsoft/TypeScript/issues/37469 | ||
const UniqueSymbol: unique symbol = Symbol('UniqueSymbol'); | ||
export type SymbolValue<Type extends Converter> = Type extends SymbolConstructor | ||
? typeof UniqueSymbol | ||
? symbol | ||
: Type extends SymbolConstructor['for'] | ||
? typeof UniqueSymbol | ||
? symbol | ||
: never; | ||
@@ -45,0 +42,0 @@ |
@@ -14,3 +14,3 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
type EnumValues<Type extends Converter, Key extends string, Keys extends string[]> = | ||
| SymbolValue<Type> | ||
| SymbolValue<Type, Key, Keys> | ||
| StringValue<Type, Key> | ||
@@ -17,0 +17,0 @@ | NumberValue<Type, Key, Keys> |
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
421158
24
2509