Support for Range in typegen for Enum (#4889)
This commit is contained in:
@@ -7,6 +7,7 @@ Changes:
|
|||||||
- Add internal merge of single storage queries
|
- Add internal merge of single storage queries
|
||||||
- Expose provider stats on API intrerface via `.stats`
|
- Expose provider stats on API intrerface via `.stats`
|
||||||
- Adjust flag extraction for latest phragmen types
|
- Adjust flag extraction for latest phragmen types
|
||||||
|
- Support for `Range` in typegen for `Enum`
|
||||||
- Add Kusama 9220 upgrade block
|
- Add Kusama 9220 upgrade block
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, {
|
|||||||
const keys = named.map((def): string => {
|
const keys = named.map((def): string => {
|
||||||
const { info, lookupName, name = '', type } = def;
|
const { info, lookupName, name = '', type } = def;
|
||||||
const getter = stringPascalCase(name.replace(' ', '_'));
|
const getter = stringPascalCase(name.replace(' ', '_'));
|
||||||
const isComplex = [TypeDefInfo.Option, TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
const isComplex = [TypeDefInfo.Option, TypeDefInfo.Range, TypeDefInfo.RangeInclusive, TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
||||||
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
||||||
? ''
|
? ''
|
||||||
: createGetter(definitions, `as${getter}`, lookupName || (isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports, false) : type), imports);
|
: createGetter(definitions, `as${getter}`, lookupName || (isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports, false) : type), imports);
|
||||||
@@ -61,6 +61,8 @@ function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, {
|
|||||||
switch (info) {
|
switch (info) {
|
||||||
case TypeDefInfo.Compact:
|
case TypeDefInfo.Compact:
|
||||||
case TypeDefInfo.Plain:
|
case TypeDefInfo.Plain:
|
||||||
|
case TypeDefInfo.Range:
|
||||||
|
case TypeDefInfo.RangeInclusive:
|
||||||
case TypeDefInfo.Result:
|
case TypeDefInfo.Result:
|
||||||
case TypeDefInfo.Si:
|
case TypeDefInfo.Si:
|
||||||
case TypeDefInfo.Struct:
|
case TypeDefInfo.Struct:
|
||||||
|
|||||||
Reference in New Issue
Block a user