Adjust named enum fields augmentation (#4919)
* Adjust named enum fields augmentation * Named tuples * Adjust sanitize for symbol * Explicit check * Remove unused code * Adjust expansion * Adjust (only keep to named tuples this round) * Pass struct
This commit is contained in:
@@ -16,6 +16,9 @@ import { compareName, createImports, formatType, initMeta, readTemplate, setImpo
|
||||
|
||||
const generateForMetaTemplate = Handlebars.compile(readTemplate('events'));
|
||||
|
||||
// For babel itself we need some extra aliasing
|
||||
const ALIAS = ['symbol'];
|
||||
|
||||
/** @internal */
|
||||
function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
|
||||
writeFile(dest, (): string => {
|
||||
@@ -50,11 +53,10 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
|
||||
return {
|
||||
docs,
|
||||
fields: names.length === args.length
|
||||
? `{ ${names.map((n, i) => `${n}: ${args[i]}`).join(', ')} }`
|
||||
: '{}',
|
||||
name: name.toString(),
|
||||
type: `[${args.join(', ')}]`
|
||||
type: names.length !== 0 && names.length === args.length
|
||||
? `[${names.map((n, i) => `${ALIAS.includes(n) ? `${n}_` : n}: ${args[i]}`).join(', ')}], { ${names.map((n, i) => `${n}: ${args[i]}`).join(', ')} }`
|
||||
: `[${args.join(', ')}]`
|
||||
};
|
||||
})
|
||||
.sort(compareName),
|
||||
|
||||
@@ -8,7 +8,7 @@ declare module '@polkadot/api-base/types/events' {
|
||||
{{{name}}}: {
|
||||
{{#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedEvent<ApiType, {{{type}}}, {{{fields}}}>;
|
||||
{{{name}}}: AugmentedEvent<ApiType, {{{type}}}>;
|
||||
{{/each}}
|
||||
{{#unless @root.isStrict}}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user