@pezkuwi/typegen 16.5.5 → 16.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/augment.js +2 -0
- package/bundle.js +2 -0
- package/cjs/augment.d.ts +2 -0
- package/cjs/augment.js +4 -0
- package/cjs/bundle.d.ts +2 -0
- package/cjs/bundle.js +7 -0
- package/cjs/extractChain.js +44 -0
- package/cjs/fromChain.js +95 -0
- package/cjs/fromDefs.js +82 -0
- package/cjs/generate/consts.js +91 -0
- package/cjs/generate/errors.js +59 -0
- package/cjs/generate/events.js +139 -0
- package/cjs/generate/index.js +23 -0
- package/cjs/generate/interfaceRegistry.js +64 -0
- package/cjs/generate/lookup.js +240 -0
- package/cjs/generate/query.js +140 -0
- package/cjs/generate/rpc.js +115 -0
- package/cjs/generate/runtime.js +233 -0
- package/{build → cjs}/generate/tsDef.d.ts +1 -1
- package/cjs/generate/tsDef.js +254 -0
- package/cjs/generate/tx.js +121 -0
- package/cjs/generate/types.js +16 -0
- package/cjs/index.js +5 -0
- package/cjs/interfacesTs.js +28 -0
- package/cjs/metadataMd.js +652 -0
- package/cjs/package.json +3 -0
- package/cjs/packageDetect.js +8 -0
- package/cjs/packageInfo.js +4 -0
- package/cjs/util/assert.js +15 -0
- package/cjs/util/derived.js +128 -0
- package/cjs/util/docs.js +10 -0
- package/cjs/util/file.js +33 -0
- package/{build → cjs}/util/formatting.d.ts +1 -1
- package/cjs/util/formatting.js +237 -0
- package/cjs/util/imports.js +126 -0
- package/{build → cjs}/util/index.d.ts +1 -0
- package/cjs/util/index.js +39 -0
- package/cjs/util/initMeta.js +22 -0
- package/cjs/util/register.js +10 -0
- package/cjs/util/wsMeta.js +60 -0
- package/extractChain.d.ts +1 -0
- package/extractChain.js +40 -0
- package/fromChain.d.ts +1 -0
- package/fromChain.js +91 -0
- package/fromDefs.d.ts +1 -0
- package/fromDefs.js +78 -0
- package/generate/consts.d.ts +5 -0
- package/generate/consts.js +87 -0
- package/generate/errors.d.ts +4 -0
- package/generate/errors.js +55 -0
- package/generate/events.d.ts +5 -0
- package/generate/events.js +135 -0
- package/{src/generate/index.ts → generate/index.d.ts} +0 -3
- package/generate/index.js +10 -0
- package/generate/interfaceRegistry.d.ts +4 -0
- package/generate/interfaceRegistry.js +59 -0
- package/generate/lookup.d.ts +4 -0
- package/generate/lookup.js +235 -0
- package/generate/query.d.ts +5 -0
- package/generate/query.js +136 -0
- package/generate/rpc.d.ts +6 -0
- package/generate/rpc.js +110 -0
- package/generate/runtime.d.ts +7 -0
- package/generate/runtime.js +228 -0
- package/generate/tsDef.d.ts +16 -0
- package/generate/tsDef.js +246 -0
- package/generate/tx.d.ts +5 -0
- package/generate/tx.js +117 -0
- package/generate/types.d.ts +12 -0
- package/generate/types.js +13 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/interfacesTs.d.ts +1 -0
- package/interfacesTs.js +24 -0
- package/metadataMd.d.ts +1 -0
- package/metadataMd.js +648 -0
- package/package.json +520 -24
- package/packageDetect.d.ts +1 -0
- package/{src/packageDetect.ts → packageDetect.js} +0 -8
- package/packageInfo.d.ts +6 -0
- package/packageInfo.js +1 -0
- package/scripts/{polkadot-types-chain-info.mjs → pezkuwi-types-chain-info.mjs} +1 -1
- package/scripts/{polkadot-types-from-chain.mjs → pezkuwi-types-from-chain.mjs} +1 -1
- package/scripts/{polkadot-types-from-defs.mjs → pezkuwi-types-from-defs.mjs} +1 -1
- package/{build/scripts/polkadot-types-internal-interfaces.mjs → scripts/pezkuwi-types-internal-interfaces.mjs} +1 -1
- package/{build/scripts/polkadot-types-internal-metadata.mjs → scripts/pezkuwi-types-internal-metadata.mjs} +1 -1
- package/{src/templates → templates}/calls.hbs +2 -2
- package/{src/templates → templates}/consts.hbs +2 -2
- package/{src/templates → templates}/errors.hbs +2 -2
- package/{src/templates → templates}/events.hbs +2 -2
- package/{src/templates → templates}/interfaceRegistry.hbs +2 -2
- package/{src/templates → templates}/lookup/types.hbs +2 -2
- package/{src/templates → templates}/query.hbs +2 -2
- package/{src/templates → templates}/rpc.hbs +2 -2
- package/{src/templates → templates}/tx.hbs +2 -2
- package/util/assert.d.ts +2 -0
- package/util/assert.js +10 -0
- package/util/derived.d.ts +4 -0
- package/util/derived.js +125 -0
- package/util/docs.d.ts +1 -0
- package/util/docs.js +6 -0
- package/util/file.d.ts +2 -0
- package/util/file.js +28 -0
- package/util/formatting.d.ts +11 -0
- package/util/formatting.js +230 -0
- package/util/imports.d.ts +23 -0
- package/util/imports.js +121 -0
- package/{src/util/index.ts → util/index.d.ts} +6 -8
- package/util/index.js +34 -0
- package/util/initMeta.d.ts +12 -0
- package/util/initMeta.js +19 -0
- package/util/register.d.ts +4 -0
- package/util/register.js +7 -0
- package/util/wsMeta.d.ts +4 -0
- package/util/wsMeta.js +55 -0
- package/build/scripts/polkadot-types-chain-info.mjs +0 -7
- package/build/scripts/polkadot-types-from-chain.mjs +0 -7
- package/build/scripts/polkadot-types-from-defs.mjs +0 -7
- package/scripts/polkadot-types-internal-interfaces.mjs +0 -7
- package/scripts/polkadot-types-internal-metadata.mjs +0 -7
- package/src/augment.ts +0 -5
- package/src/bundle.ts +0 -5
- package/src/extractChain.ts +0 -54
- package/src/fromChain.ts +0 -123
- package/src/fromDefs.ts +0 -106
- package/src/generate/consts.ts +0 -112
- package/src/generate/errors.ts +0 -75
- package/src/generate/events.ts +0 -165
- package/src/generate/interfaceRegistry.ts +0 -85
- package/src/generate/lookup.ts +0 -294
- package/src/generate/query.ts +0 -169
- package/src/generate/rpc.ts +0 -158
- package/src/generate/runtime.ts +0 -284
- package/src/generate/tsDef.ts +0 -321
- package/src/generate/tx.ts +0 -152
- package/src/generate/types.ts +0 -26
- package/src/index.ts +0 -6
- package/src/interfacesTs.ts +0 -35
- package/src/metadataMd.ts +0 -844
- package/src/packageInfo.ts +0 -6
- package/src/util/assert.ts +0 -18
- package/src/util/derived.spec.ts +0 -58
- package/src/util/derived.ts +0 -133
- package/src/util/docs.ts +0 -13
- package/src/util/file.ts +0 -42
- package/src/util/formatting.spec.ts +0 -30
- package/src/util/formatting.ts +0 -295
- package/src/util/imports.ts +0 -164
- package/src/util/initMeta.ts +0 -37
- package/src/util/register.ts +0 -12
- package/src/util/wsMeta.ts +0 -70
- package/tsconfig.build.json +0 -28
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.scripts.json +0 -19
- package/tsconfig.spec.json +0 -17
- /package/{build/augment.d.ts → augment.d.ts} +0 -0
- /package/{build/bundle.d.ts → bundle.d.ts} +0 -0
- /package/{build → cjs}/extractChain.d.ts +0 -0
- /package/{build → cjs}/fromChain.d.ts +0 -0
- /package/{build → cjs}/fromDefs.d.ts +0 -0
- /package/{build → cjs}/generate/consts.d.ts +0 -0
- /package/{build → cjs}/generate/errors.d.ts +0 -0
- /package/{build → cjs}/generate/events.d.ts +0 -0
- /package/{build → cjs}/generate/index.d.ts +0 -0
- /package/{build → cjs}/generate/interfaceRegistry.d.ts +0 -0
- /package/{build → cjs}/generate/lookup.d.ts +0 -0
- /package/{build → cjs}/generate/query.d.ts +0 -0
- /package/{build → cjs}/generate/rpc.d.ts +0 -0
- /package/{build → cjs}/generate/runtime.d.ts +0 -0
- /package/{build → cjs}/generate/tx.d.ts +0 -0
- /package/{build → cjs}/generate/types.d.ts +0 -0
- /package/{build → cjs}/index.d.ts +0 -0
- /package/{build → cjs}/interfacesTs.d.ts +0 -0
- /package/{build → cjs}/metadataMd.d.ts +0 -0
- /package/{build → cjs}/packageDetect.d.ts +0 -0
- /package/{build → cjs}/packageInfo.d.ts +0 -0
- /package/{build → cjs}/util/assert.d.ts +0 -0
- /package/{build → cjs}/util/derived.d.ts +0 -0
- /package/{build → cjs}/util/docs.d.ts +0 -0
- /package/{build → cjs}/util/file.d.ts +0 -0
- /package/{build → cjs}/util/imports.d.ts +0 -0
- /package/{build → cjs}/util/initMeta.d.ts +0 -0
- /package/{build → cjs}/util/register.d.ts +0 -0
- /package/{build → cjs}/util/wsMeta.d.ts +0 -0
- /package/{src/templates → templates}/docs.hbs +0 -0
- /package/{src/templates → templates}/header.hbs +0 -0
- /package/{src/templates → templates}/lookup/defs-named.hbs +0 -0
- /package/{src/templates → templates}/lookup/defs.hbs +0 -0
- /package/{src/templates → templates}/lookup/index.hbs +0 -0
- /package/{src/templates → templates}/tsDef/index.hbs +0 -0
- /package/{src/templates → templates}/tsDef/moduleTypes.hbs +0 -0
- /package/{src/templates → templates}/tsDef/types.hbs +0 -0
package/src/packageInfo.ts
DELETED
package/src/util/assert.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/typegen authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
|
|
6
|
-
import { assert } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
export function assertDir (path: string): string {
|
|
9
|
-
assert(fs.existsSync(path) && fs.lstatSync(path).isDirectory(), `${path} is not a directory`);
|
|
10
|
-
|
|
11
|
-
return path;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function assertFile (path: string): string {
|
|
15
|
-
assert(fs.existsSync(path) && fs.lstatSync(path).isFile(), `${path} is not a file`);
|
|
16
|
-
|
|
17
|
-
return path;
|
|
18
|
-
}
|
package/src/util/derived.spec.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/typegen authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import { TypeRegistry } from '@pezkuwi/types/create';
|
|
7
|
-
|
|
8
|
-
import { getSimilarTypes } from './derived.js';
|
|
9
|
-
|
|
10
|
-
describe('getSimilarTypes', (): void => {
|
|
11
|
-
const registry = new TypeRegistry();
|
|
12
|
-
const mockImports = {
|
|
13
|
-
codecTypes: {},
|
|
14
|
-
definitions: {},
|
|
15
|
-
extrinsicTypes: {},
|
|
16
|
-
genericTypes: {},
|
|
17
|
-
ignoredTypes: [],
|
|
18
|
-
localTypes: {},
|
|
19
|
-
lookupTypes: {},
|
|
20
|
-
metadataTypes: {},
|
|
21
|
-
primitiveTypes: {},
|
|
22
|
-
typeToModule: {},
|
|
23
|
-
typesTypes: {}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
it('handles nested Tuples', (): void => {
|
|
27
|
-
expect(getSimilarTypes(registry, {}, '(AccountId, (Balance, u32), u64)', mockImports)).toEqual([
|
|
28
|
-
'ITuple<[AccountId, ITuple<[Balance, u32]>, u64]>',
|
|
29
|
-
'[AccountId | string | Uint8Array, ITuple<[Balance, u32]> | [Balance | AnyNumber | Uint8Array, u32 | AnyNumber | Uint8Array], u64 | AnyNumber | Uint8Array]'
|
|
30
|
-
]);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('handles vectors of slices', (): void => {
|
|
34
|
-
expect(getSimilarTypes(registry, {}, 'Vec<[u8;4]>', mockImports)).toEqual([
|
|
35
|
-
'Vec<U8aFixed>'
|
|
36
|
-
]);
|
|
37
|
-
expect(getSimilarTypes(registry, {}, 'Vec<[Balance;8]>', mockImports)).toEqual([
|
|
38
|
-
'Vec<Vec<Balance>>'
|
|
39
|
-
]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('handles structs', (): void => {
|
|
43
|
-
expect(getSimilarTypes(registry, {}, '{ "a": "u8", "b": "Vec<u8>" }', mockImports)).toEqual([
|
|
44
|
-
`{
|
|
45
|
-
readonly a: u8;
|
|
46
|
-
readonly b: Bytes;
|
|
47
|
-
} & Struct`, '{ a?: any; b?: any }', 'string', 'Uint8Array'
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
it('handles vectors of structs', (): void => {
|
|
51
|
-
expect(getSimilarTypes(registry, {}, 'Vec<{ "a": "H256", "b": "Vec<H256>" }>', mockImports)).toEqual([
|
|
52
|
-
`Vec<{
|
|
53
|
-
readonly a: H256;
|
|
54
|
-
readonly b: Vec<H256>;
|
|
55
|
-
} & Struct>`
|
|
56
|
-
]);
|
|
57
|
-
});
|
|
58
|
-
});
|
package/src/util/derived.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/types authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { CodecClass, Registry } from '@pezkuwi/types/types';
|
|
5
|
-
import type { UInt } from '@pezkuwi/types-codec';
|
|
6
|
-
import type { TypeDef } from '@pezkuwi/types-create/types';
|
|
7
|
-
import type { ModuleTypes, TypeImports } from './imports.js';
|
|
8
|
-
|
|
9
|
-
import { GenericAccountId, GenericCall, GenericLookupSource, GenericVote } from '@pezkuwi/types/generic';
|
|
10
|
-
import { AllConvictions } from '@pezkuwi/types/interfaces/democracy/definitions';
|
|
11
|
-
import { AbstractInt, bool, Compact, Enum, Null, Option, Struct, Tuple, Vec, WrapperKeepOpaque, WrapperOpaque } from '@pezkuwi/types-codec';
|
|
12
|
-
import { getTypeDef, TypeDefInfo } from '@pezkuwi/types-create';
|
|
13
|
-
import { isChildClass, stringify } from '@pezkuwi/util';
|
|
14
|
-
|
|
15
|
-
import { formatType } from './formatting.js';
|
|
16
|
-
import { setImports } from './imports.js';
|
|
17
|
-
|
|
18
|
-
function arrayToStrType (arr: string[]): string {
|
|
19
|
-
return `${arr.map((c) => `'${c}'`).join(' | ')}`;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const voteConvictions = arrayToStrType(AllConvictions);
|
|
23
|
-
|
|
24
|
-
// Make types a little bit more flexible
|
|
25
|
-
// - if param instanceof AbstractInt, then param: u64 | Uint8array | AnyNumber
|
|
26
|
-
// etc
|
|
27
|
-
/** @internal */
|
|
28
|
-
export function getSimilarTypes (registry: Registry, definitions: Record<string, ModuleTypes>, _type: string, imports: TypeImports): string[] {
|
|
29
|
-
const typeParts = _type.split('::');
|
|
30
|
-
const type = typeParts[typeParts.length - 1];
|
|
31
|
-
const possibleTypes = [formatType(registry, definitions, type, imports)];
|
|
32
|
-
|
|
33
|
-
if (type === 'Extrinsic') {
|
|
34
|
-
setImports(definitions, imports, ['IExtrinsic']);
|
|
35
|
-
|
|
36
|
-
return ['Extrinsic', 'IExtrinsic', 'string', 'Uint8Array'];
|
|
37
|
-
} else if (type === 'Keys') {
|
|
38
|
-
// This one is weird... surely it should popup as a Tuple? (but either way better as defined hex)
|
|
39
|
-
return ['Keys', 'string', 'Uint8Array'];
|
|
40
|
-
} else if (type === 'StorageKey') {
|
|
41
|
-
// TODO We can do better
|
|
42
|
-
return ['StorageKey', 'string', 'Uint8Array', 'any'];
|
|
43
|
-
} else if (type === '()') {
|
|
44
|
-
return ['null'];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const Clazz = registry.createClass(type);
|
|
48
|
-
|
|
49
|
-
if (isChildClass(Vec, Clazz)) {
|
|
50
|
-
const vecDef = getTypeDef(type);
|
|
51
|
-
const subDef = (vecDef.sub) as TypeDef;
|
|
52
|
-
|
|
53
|
-
// this could be that we define a Vec type and refer to it by name
|
|
54
|
-
if (subDef) {
|
|
55
|
-
if (subDef.info === TypeDefInfo.Plain) {
|
|
56
|
-
possibleTypes.push(`(${getSimilarTypes(registry, definitions, subDef.type, imports).join(' | ')})[]`);
|
|
57
|
-
} else if (subDef.info === TypeDefInfo.Tuple) {
|
|
58
|
-
const subs = (subDef.sub as TypeDef[]).map(({ type }): string =>
|
|
59
|
-
getSimilarTypes(registry, definitions, type, imports).join(' | ')
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
possibleTypes.push(`([${subs.join(', ')}])[]`);
|
|
63
|
-
} else if (subDef.info === TypeDefInfo.Option || subDef.info === TypeDefInfo.Vec || subDef.info === TypeDefInfo.VecFixed) {
|
|
64
|
-
// TODO: Add possibleTypes so imports work
|
|
65
|
-
} else if (subDef.info === TypeDefInfo.Struct) {
|
|
66
|
-
// TODO: Add possibleTypes so imports work
|
|
67
|
-
} else {
|
|
68
|
-
throw new Error(`Unhandled subtype in Vec, ${stringify(subDef)}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
} else if (isChildClass(Enum, Clazz)) {
|
|
72
|
-
const { defKeys, isBasic } = new (Clazz as CodecClass)(registry) as Enum;
|
|
73
|
-
const keys = defKeys.filter((v) => !v.startsWith('__Unused'));
|
|
74
|
-
|
|
75
|
-
if (isBasic) {
|
|
76
|
-
possibleTypes.push(arrayToStrType(keys), 'number');
|
|
77
|
-
} else {
|
|
78
|
-
// TODO We don't really want any here, these should be expanded
|
|
79
|
-
possibleTypes.push(...keys.map((k) => `{ ${k}: any }`), 'string');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
possibleTypes.push('Uint8Array');
|
|
83
|
-
} else if (isChildClass(AbstractInt as unknown as CodecClass<UInt>, Clazz) || isChildClass(Compact, Clazz)) {
|
|
84
|
-
possibleTypes.push('AnyNumber', 'Uint8Array');
|
|
85
|
-
} else if (isChildClass(GenericLookupSource, Clazz)) {
|
|
86
|
-
possibleTypes.push('Address', 'AccountId', 'AccountIndex', 'LookupSource', 'string', 'Uint8Array');
|
|
87
|
-
} else if (isChildClass(GenericAccountId, Clazz)) {
|
|
88
|
-
possibleTypes.push('string', 'Uint8Array');
|
|
89
|
-
} else if (isChildClass(GenericCall, Clazz)) {
|
|
90
|
-
possibleTypes.push('IMethod', 'string', 'Uint8Array');
|
|
91
|
-
} else if (isChildClass(bool, Clazz)) {
|
|
92
|
-
possibleTypes.push('boolean', 'Uint8Array');
|
|
93
|
-
} else if (isChildClass(Null, Clazz)) {
|
|
94
|
-
possibleTypes.push('null');
|
|
95
|
-
} else if (isChildClass(Struct, Clazz)) {
|
|
96
|
-
const s = new (Clazz as CodecClass)(registry) as Struct;
|
|
97
|
-
const obj = s.defKeys.map((key): string => `${key}?: any`).join('; ');
|
|
98
|
-
|
|
99
|
-
possibleTypes.push(`{ ${obj} }`, 'string', 'Uint8Array');
|
|
100
|
-
} else if (isChildClass(Option, Clazz)) {
|
|
101
|
-
possibleTypes.push('null', 'Uint8Array');
|
|
102
|
-
|
|
103
|
-
const optDef = getTypeDef(type);
|
|
104
|
-
const subDef = (optDef.sub) as TypeDef;
|
|
105
|
-
|
|
106
|
-
if (subDef) {
|
|
107
|
-
possibleTypes.push(...getSimilarTypes(registry, definitions, subDef.type, imports));
|
|
108
|
-
} else {
|
|
109
|
-
possibleTypes.push('object', 'string');
|
|
110
|
-
}
|
|
111
|
-
} else if (isChildClass(GenericVote, Clazz)) {
|
|
112
|
-
possibleTypes.push(`{ aye: boolean; conviction?: ${voteConvictions} | number }`, 'boolean', 'string', 'Uint8Array');
|
|
113
|
-
} else if (isChildClass(WrapperKeepOpaque, Clazz) || isChildClass(WrapperOpaque, Clazz)) {
|
|
114
|
-
// TODO inspect container
|
|
115
|
-
possibleTypes.push('object', 'string', 'Uint8Array');
|
|
116
|
-
} else if (isChildClass(Uint8Array, Clazz)) {
|
|
117
|
-
possibleTypes.push('string', 'Uint8Array');
|
|
118
|
-
} else if (isChildClass(String, Clazz)) {
|
|
119
|
-
possibleTypes.push('string');
|
|
120
|
-
} else if (isChildClass(Tuple, Clazz)) {
|
|
121
|
-
const tupDef = getTypeDef(type);
|
|
122
|
-
const subDef = tupDef.sub;
|
|
123
|
-
|
|
124
|
-
// this could be that we define a Tuple type and refer to it by name
|
|
125
|
-
if (Array.isArray(subDef)) {
|
|
126
|
-
const subs = subDef.map(({ type }) => getSimilarTypes(registry, definitions, type, imports).join(' | '));
|
|
127
|
-
|
|
128
|
-
possibleTypes.push(`[${subs.join(', ')}]`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return [...new Set(possibleTypes)];
|
|
133
|
-
}
|
package/src/util/docs.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/typegen authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import Handlebars from 'handlebars';
|
|
5
|
-
|
|
6
|
-
import { readTemplate } from './file.js';
|
|
7
|
-
|
|
8
|
-
Handlebars.registerPartial({
|
|
9
|
-
docs: Handlebars.compile(readTemplate('docs'))
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// empty export
|
|
13
|
-
export const __TYPEGEN_DUMMY_DOCS = 'DUMMY_DOCS';
|
package/src/util/file.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/typegen authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import process from 'node:process';
|
|
7
|
-
|
|
8
|
-
import { packageInfo } from '../packageInfo.js';
|
|
9
|
-
|
|
10
|
-
export function writeFile (dest: string, generator: () => string, noLog?: boolean): void {
|
|
11
|
-
!noLog && console.log(`${dest}\n\tGenerating`);
|
|
12
|
-
|
|
13
|
-
let generated = generator();
|
|
14
|
-
|
|
15
|
-
while (generated.includes('\n\n\n')) {
|
|
16
|
-
generated = generated.replace(/\n\n\n/g, '\n\n');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
!noLog && console.log('\tWriting');
|
|
20
|
-
|
|
21
|
-
fs.writeFileSync(dest, generated, { flag: 'w' });
|
|
22
|
-
|
|
23
|
-
!noLog && console.log('');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function readTemplate (template: string): string {
|
|
27
|
-
// Inside the api repo itself, it will be 'auto'
|
|
28
|
-
const rootDir = packageInfo.path === 'auto'
|
|
29
|
-
? path.join(process.cwd(), 'packages/typegen/src')
|
|
30
|
-
: packageInfo.path;
|
|
31
|
-
|
|
32
|
-
// NOTE With cjs in a subdir, search one lower as well
|
|
33
|
-
const file = ['./templates', '../templates']
|
|
34
|
-
.map((p) => path.join(rootDir, p, `${template}.hbs`))
|
|
35
|
-
.find((p) => fs.existsSync(p));
|
|
36
|
-
|
|
37
|
-
if (!file) {
|
|
38
|
-
throw new Error(`Unable to locate ${template}.hbs from ${rootDir}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return fs.readFileSync(file).toString();
|
|
42
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/typegen authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import { TypeRegistry } from '@pezkuwi/types';
|
|
7
|
-
|
|
8
|
-
import { formatType } from './formatting.js';
|
|
9
|
-
|
|
10
|
-
describe('formatType', (): void => {
|
|
11
|
-
const registry = new TypeRegistry();
|
|
12
|
-
|
|
13
|
-
it('handles nested Tuples', (): void => {
|
|
14
|
-
expect(
|
|
15
|
-
formatType(registry, {}, '(AccountId, (Balance, u32), u64)', {
|
|
16
|
-
codecTypes: {},
|
|
17
|
-
definitions: {},
|
|
18
|
-
extrinsicTypes: {},
|
|
19
|
-
genericTypes: {},
|
|
20
|
-
ignoredTypes: [],
|
|
21
|
-
localTypes: {},
|
|
22
|
-
lookupTypes: {},
|
|
23
|
-
metadataTypes: {},
|
|
24
|
-
primitiveTypes: {},
|
|
25
|
-
typeToModule: {},
|
|
26
|
-
typesTypes: {}
|
|
27
|
-
})
|
|
28
|
-
).toEqual('ITuple<[AccountId, ITuple<[Balance, u32]>, u64]>');
|
|
29
|
-
});
|
|
30
|
-
});
|
package/src/util/formatting.ts
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/typegen authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { AnyString, Registry } from '@pezkuwi/types/types';
|
|
5
|
-
import type { LookupString } from '@pezkuwi/types-codec/types';
|
|
6
|
-
import type { TypeDef } from '@pezkuwi/types-create/types';
|
|
7
|
-
import type { ModuleTypes, TypeImports } from './imports.js';
|
|
8
|
-
|
|
9
|
-
import Handlebars from 'handlebars';
|
|
10
|
-
|
|
11
|
-
import * as typesCodec from '@pezkuwi/types-codec';
|
|
12
|
-
import { getTypeDef, paramsNotation, TypeDefInfo } from '@pezkuwi/types-create';
|
|
13
|
-
import { isString, stringify } from '@pezkuwi/util';
|
|
14
|
-
|
|
15
|
-
import { readTemplate } from './file.js';
|
|
16
|
-
import { setImports } from './imports.js';
|
|
17
|
-
|
|
18
|
-
interface ImportDef {
|
|
19
|
-
file: string;
|
|
20
|
-
types: string[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface This {
|
|
24
|
-
imports: TypeImports;
|
|
25
|
-
types: ImportDef[];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const NO_CODEC = ['Tuple', 'VecFixed'];
|
|
29
|
-
const ON_CODEC = Object.keys(typesCodec);
|
|
30
|
-
const ON_CODEC_TYPES = ['Codec', 'AnyJson', 'AnyFunction', 'AnyNumber', 'AnyString', 'AnyTuple', 'AnyU8a', 'ICompact', 'IEnum', 'IMap', 'INumber', 'IOption', 'IResult', 'ISet', 'IStruct', 'ITuple', 'IU8a', 'IVec', 'IMethod'];
|
|
31
|
-
|
|
32
|
-
export const HEADER = (type: 'chain' | 'defs'): string => `// Auto-generated via \`yarn polkadot-types-from-${type}\`, do not edit\n/* eslint-disable */\n\n`;
|
|
33
|
-
|
|
34
|
-
function extractImports ({ imports, types }: This): string[] {
|
|
35
|
-
const toplevel = [
|
|
36
|
-
...Object.keys(imports.codecTypes),
|
|
37
|
-
...Object.keys(imports.extrinsicTypes),
|
|
38
|
-
...Object.keys(imports.genericTypes),
|
|
39
|
-
...Object.keys(imports.metadataTypes),
|
|
40
|
-
...Object.keys(imports.primitiveTypes)
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
return [
|
|
44
|
-
{
|
|
45
|
-
file: '@pezkuwi/types',
|
|
46
|
-
types: toplevel.filter((n) =>
|
|
47
|
-
!NO_CODEC.includes(n) && !ON_CODEC.includes(n)
|
|
48
|
-
)
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
file: '@pezkuwi/types/lookup',
|
|
52
|
-
types: Object.keys(imports.lookupTypes)
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
file: '@pezkuwi/types/types',
|
|
56
|
-
types: Object.keys(imports.typesTypes).filter((n) =>
|
|
57
|
-
!ON_CODEC_TYPES.includes(n)
|
|
58
|
-
)
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
file: '@pezkuwi/types-codec',
|
|
62
|
-
types: toplevel.filter((n) =>
|
|
63
|
-
!NO_CODEC.includes(n) && ON_CODEC.includes(n)
|
|
64
|
-
)
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
file: '@pezkuwi/types-codec/types',
|
|
68
|
-
types: Object.keys(imports.typesTypes).filter((n) =>
|
|
69
|
-
ON_CODEC_TYPES.includes(n)
|
|
70
|
-
)
|
|
71
|
-
},
|
|
72
|
-
...types
|
|
73
|
-
]
|
|
74
|
-
.filter(({ types }) => types.length)
|
|
75
|
-
.sort(({ file }, b) => file.localeCompare(b.file))
|
|
76
|
-
.map(({ file, types }) => `import type { ${types.sort().join(', ')} } from '${file}';`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
Handlebars.registerPartial({
|
|
80
|
-
header: Handlebars.compile(readTemplate('header'))
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
Handlebars.registerHelper({
|
|
84
|
-
importsAll () {
|
|
85
|
-
return extractImports(this as unknown as This)
|
|
86
|
-
.join('\n');
|
|
87
|
-
},
|
|
88
|
-
importsPackage () {
|
|
89
|
-
return extractImports(this as unknown as This)
|
|
90
|
-
.filter((l) => !l.includes("from '."))
|
|
91
|
-
.join('\n ');
|
|
92
|
-
},
|
|
93
|
-
importsRelative () {
|
|
94
|
-
return extractImports(this as unknown as This)
|
|
95
|
-
.filter((l) => l.includes("from '."))
|
|
96
|
-
.join('\n');
|
|
97
|
-
},
|
|
98
|
-
trim (options: { fn: (self: unknown) => string }) {
|
|
99
|
-
return options.fn(this).trim();
|
|
100
|
-
},
|
|
101
|
-
upper (options: { fn: (self: unknown) => string }) {
|
|
102
|
-
return options.fn(this).toUpperCase();
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// helper to generate a `export interface <Name> extends <Base> {<Body>}
|
|
107
|
-
/** @internal */
|
|
108
|
-
export function exportInterface (lookupIndex = -1, name = '', base: string, body = '', withShortcut = false): string {
|
|
109
|
-
// * @description extends [[${base}]]
|
|
110
|
-
const doc = withShortcut
|
|
111
|
-
? ''
|
|
112
|
-
: `/** @name ${name}${lookupIndex !== -1 ? ` (${lookupIndex})` : ''} */\n`;
|
|
113
|
-
|
|
114
|
-
return `${doc}${withShortcut ? '' : `export interface ${name} extends ${base} `}{${body.length ? '\n' : ''}${body}${withShortcut ? ' ' : ''}}`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function singleParamNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
|
|
118
|
-
const sub = (typeDef.sub as TypeDef);
|
|
119
|
-
|
|
120
|
-
setImports(definitions, imports, [wrapper, sub.lookupName]);
|
|
121
|
-
|
|
122
|
-
return paramsNotation(wrapper, sub.lookupName || formatType(registry, definitions, sub.type, imports, withShortcut));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function dualParamsNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
|
|
126
|
-
const [a, b] = (typeDef.sub as TypeDef[]);
|
|
127
|
-
|
|
128
|
-
setImports(definitions, imports, [wrapper, a.lookupName, b.lookupName]);
|
|
129
|
-
|
|
130
|
-
return paramsNotation(wrapper, [
|
|
131
|
-
a.lookupName || formatType(registry, definitions, a.type, imports, withShortcut),
|
|
132
|
-
b.lookupName || formatType(registry, definitions, b.type, imports, withShortcut)
|
|
133
|
-
]);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => string> = {
|
|
137
|
-
[TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
138
|
-
return singleParamNotation(registry, 'Compact', typeDef, definitions, imports, withShortcut);
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
[TypeDefInfo.DoNotConstruct]: (_registry: Registry, _typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, _withShortcut: boolean) => {
|
|
142
|
-
setImports(definitions, imports, ['DoNotConstruct']);
|
|
143
|
-
|
|
144
|
-
return 'DoNotConstruct';
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
[TypeDefInfo.Enum]: (_registry: Registry, typeDef: TypeDef, _definitions: Record<string, ModuleTypes>, _imports: TypeImports, _withShortcut: boolean) => {
|
|
148
|
-
if (typeDef.lookupName) {
|
|
149
|
-
return typeDef.lookupName;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
throw new Error(`TypeDefInfo.Enum: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
[TypeDefInfo.Int]: (_registry: Registry, typeDef: TypeDef, _definitions: Record<string, ModuleTypes>, _imports: TypeImports, _withShortcut: boolean) => {
|
|
156
|
-
throw new Error(`TypeDefInfo.Int: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
[TypeDefInfo.UInt]: (_registry: Registry, typeDef: TypeDef, _definitions: Record<string, ModuleTypes>, _imports: TypeImports, _withShortcut: boolean) => {
|
|
160
|
-
throw new Error(`TypeDefInfo.UInt: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
[TypeDefInfo.Null]: (_registry: Registry, _typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, _withShortcut: boolean) => {
|
|
164
|
-
setImports(definitions, imports, ['Null']);
|
|
165
|
-
|
|
166
|
-
return 'Null';
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
[TypeDefInfo.Option]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
170
|
-
return singleParamNotation(registry, 'Option', typeDef, definitions, imports, withShortcut);
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
[TypeDefInfo.Plain]: (_registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, _withShortcut: boolean) => {
|
|
174
|
-
setImports(definitions, imports, [typeDef.type]);
|
|
175
|
-
|
|
176
|
-
return typeDef.type;
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
[TypeDefInfo.Range]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
180
|
-
return singleParamNotation(registry, 'Range', typeDef, definitions, imports, withShortcut);
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
[TypeDefInfo.RangeInclusive]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
184
|
-
return singleParamNotation(registry, 'RangeInclusive', typeDef, definitions, imports, withShortcut);
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
[TypeDefInfo.Set]: (_registry: Registry, typeDef: TypeDef, _definitions: Record<string, ModuleTypes>, _imports: TypeImports, _withShortcut: boolean) => {
|
|
188
|
-
throw new Error(`TypeDefInfo.Set: Parameter formatting not implemented on ${stringify(typeDef)}`);
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
[TypeDefInfo.Si]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
192
|
-
return formatType(registry, definitions, registry.lookup.getTypeDef(typeDef.type as LookupString), imports, withShortcut);
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
[TypeDefInfo.Struct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
196
|
-
if (typeDef.lookupName) {
|
|
197
|
-
return typeDef.lookupName;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const sub = typeDef.sub as TypeDef[];
|
|
201
|
-
|
|
202
|
-
setImports(definitions, imports, ['Struct', ...sub.map(({ lookupName }) => lookupName)]);
|
|
203
|
-
|
|
204
|
-
return `{${withShortcut ? ' ' : '\n'}${
|
|
205
|
-
sub.map(({ lookupName, name, type }, index) => [
|
|
206
|
-
name || `unknown${index}`,
|
|
207
|
-
lookupName || formatType(registry, definitions, type, imports, withShortcut)
|
|
208
|
-
]).map(([k, t]) => `${withShortcut ? '' : ' readonly '}${k}: ${t};`).join(withShortcut ? ' ' : '\n')
|
|
209
|
-
}${withShortcut ? ' ' : '\n '}} & Struct`;
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
[TypeDefInfo.Tuple]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
213
|
-
const sub = typeDef.sub as TypeDef[];
|
|
214
|
-
|
|
215
|
-
setImports(definitions, imports, ['ITuple', ...sub.map(({ lookupName }) => lookupName)]);
|
|
216
|
-
|
|
217
|
-
// `(a,b)` gets transformed into `ITuple<[a, b]>`
|
|
218
|
-
return paramsNotation('ITuple', `[${
|
|
219
|
-
sub.map(({ lookupName, type }) =>
|
|
220
|
-
lookupName || formatType(registry, definitions, type, imports, withShortcut)
|
|
221
|
-
).join(', ')
|
|
222
|
-
}]`);
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
[TypeDefInfo.Vec]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
226
|
-
return singleParamNotation(registry, 'Vec', typeDef, definitions, imports, withShortcut);
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
[TypeDefInfo.VecFixed]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
230
|
-
const sub = (typeDef.sub as TypeDef);
|
|
231
|
-
|
|
232
|
-
if (sub.type === 'u8') {
|
|
233
|
-
setImports(definitions, imports, ['U8aFixed']);
|
|
234
|
-
|
|
235
|
-
return 'U8aFixed';
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return singleParamNotation(registry, 'Vec', typeDef, definitions, imports, withShortcut);
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
[TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
242
|
-
return dualParamsNotation(registry, 'BTreeMap', typeDef, definitions, imports, withShortcut);
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
[TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
246
|
-
return singleParamNotation(registry, 'BTreeSet', typeDef, definitions, imports, withShortcut);
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
[TypeDefInfo.HashMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
250
|
-
return dualParamsNotation(registry, 'HashMap', typeDef, definitions, imports, withShortcut);
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
[TypeDefInfo.Linkage]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
254
|
-
return singleParamNotation(registry, 'Linkage', typeDef, definitions, imports, withShortcut);
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
[TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
258
|
-
return dualParamsNotation(registry, 'Result', typeDef, definitions, imports, withShortcut);
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
[TypeDefInfo.WrapperKeepOpaque]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
262
|
-
return singleParamNotation(registry, 'WrapperKeepOpaque', typeDef, definitions, imports, withShortcut);
|
|
263
|
-
},
|
|
264
|
-
|
|
265
|
-
[TypeDefInfo.WrapperOpaque]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
|
266
|
-
return singleParamNotation(registry, 'WrapperOpaque', typeDef, definitions, imports, withShortcut);
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Correctly format a given type
|
|
272
|
-
*/
|
|
273
|
-
/** @internal */
|
|
274
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
275
|
-
export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: AnyString | TypeDef, imports: TypeImports, withShortcut = false): string {
|
|
276
|
-
let typeDef: TypeDef;
|
|
277
|
-
|
|
278
|
-
if (isString(type)) {
|
|
279
|
-
const _type = type.toString();
|
|
280
|
-
|
|
281
|
-
// If type is "unorthodox" (i.e. `{ something: any }` for an Enum input or `[a | b | c, d | e | f]` for a Tuple's similar types),
|
|
282
|
-
// we return it as-is
|
|
283
|
-
if (withShortcut && /(^{.+:.+})|^\([^,]+\)|^\(.+\)\[\]|^\[.+\]/.exec(_type) && !/\[\w+;\w+\]/.exec(_type)) {
|
|
284
|
-
return _type;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
typeDef = getTypeDef(type);
|
|
288
|
-
} else {
|
|
289
|
-
typeDef = type;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
setImports(definitions, imports, [typeDef.lookupName || typeDef.type]);
|
|
293
|
-
|
|
294
|
-
return formatters[typeDef.info](registry, typeDef, definitions, imports, withShortcut);
|
|
295
|
-
}
|