Move type-only imports (w/ verbatimModuleSyntax) (#5574)

This commit is contained in:
Jaco
2023-04-02 09:53:37 +03:00
committed by GitHub
parent 9a92089810
commit 186cfc93b5
24 changed files with 55 additions and 47 deletions
+1 -1
View File
@@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Definitions, DefinitionsTypes } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import fs from 'node:fs';
@@ -8,7 +9,6 @@ import path from 'node:path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { Definitions, DefinitionsTypes } from '@polkadot/types/types';
import { formatNumber, isHex } from '@polkadot/util';
import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultQuery, generateDefaultRpc, generateDefaultRuntime, generateDefaultTx } from './generate/index.js';
+1 -1
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/types/metadata/Metadata';
import type { Definitions } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { ExtraTypes } from './types.js';
import Handlebars from 'handlebars';
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { Definitions } from '@polkadot/types/types';
import lookupDefinitions from '@polkadot/types-augment/lookup/definitions';
import { stringCamelCase } from '@polkadot/util';
+1 -1
View File
@@ -2,13 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
import type { Metadata } from '@polkadot/types/metadata/Metadata';
import type { Definitions } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { ExtraTypes } from './types.js';
import Handlebars from 'handlebars';
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
import { Definitions } from '@polkadot/types/types';
import lookupDefinitions from '@polkadot/types-augment/lookup/definitions';
import { stringCamelCase } from '@polkadot/util';
@@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ModuleTypes } from '../util/imports.js';
import Handlebars from 'handlebars';
import { Json, Raw } from '@polkadot/types/codec';
@@ -8,7 +10,6 @@ import { TypeRegistry } from '@polkadot/types/create';
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import * as defaultPrimitives from '@polkadot/types/primitive';
import { ModuleTypes } from '../util/imports.js';
import { createImports, readTemplate, setImports, writeFile } from '../util/index.js';
const primitiveClasses = {
+1 -1
View File
@@ -3,6 +3,7 @@
import type { PortableType, SiLookupTypeId, SiPath, SiTypeParameter } from '@polkadot/types/interfaces';
import type { PortableRegistry } from '@polkadot/types/metadata';
import type { Registry } from '@polkadot/types/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { HexString } from '@polkadot/util/types';
@@ -10,7 +11,6 @@ import Handlebars from 'handlebars';
import path from 'path';
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import { Registry } from '@polkadot/types/types';
import staticKusama from '@polkadot/types-support/metadata/static-kusama';
import staticPolkadot from '@polkadot/types-support/metadata/static-polkadot';
import staticSubstrate from '@polkadot/types-support/metadata/static-substrate';
+3 -2
View File
@@ -5,6 +5,8 @@ import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces';
import type { Metadata, PortableRegistry } from '@polkadot/types/metadata';
import type { Definitions, Registry } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { ModuleTypes } from '../util/imports.js';
import type { TypeImports } from '../util/index.js';
import type { ExtraTypes } from './types.js';
import Handlebars from 'handlebars';
@@ -14,8 +16,7 @@ import { unwrapStorageSi } from '@polkadot/types/primitive/StorageKey';
import lookupDefinitions from '@polkadot/types-augment/lookup/definitions';
import { stringCamelCase } from '@polkadot/util';
import { ModuleTypes } from '../util/imports.js';
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, TypeImports, writeFile } from '../util/index.js';
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util/index.js';
const generateForMetaTemplate = Handlebars.compile(readTemplate('query'));
+2 -1
View File
@@ -4,6 +4,7 @@
import type { Registry } from '@polkadot/types/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { ModuleTypes } from '../util/imports.js';
import type { TypeImports } from '../util/index.js';
import Handlebars from 'handlebars';
import path from 'path';
@@ -13,7 +14,7 @@ import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
import { getTypeDef, TypeDefInfo } from '@polkadot/types-create';
import { assert, isString, stringify, stringPascalCase } from '@polkadot/util';
import { createImports, exportInterface, formatType, readTemplate, setImports, TypeImports, writeFile } from '../util/index.js';
import { createImports, exportInterface, formatType, readTemplate, setImports, writeFile } from '../util/index.js';
interface Imports extends TypeImports {
interfaces: [string, string][];
+2 -1
View File
@@ -3,6 +3,7 @@
import type { Constructor, Registry } from '@polkadot/types/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { ModuleTypes, TypeImports } from './imports.js';
import { GenericAccountId, GenericCall, GenericLookupSource, GenericVote } from '@polkadot/types/generic';
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
@@ -11,7 +12,7 @@ import { getTypeDef, TypeDefInfo } from '@polkadot/types-create';
import { isChildClass, stringify } from '@polkadot/util';
import { formatType } from './formatting.js';
import { ModuleTypes, setImports, TypeImports } from './imports.js';
import { setImports } from './imports.js';
function arrayToStrType (arr: string[]): string {
return `${arr.map((c) => `'${c}'`).join(' | ')}`;
+2 -1
View File
@@ -4,6 +4,7 @@
import type { AnyString, Registry } from '@polkadot/types/types';
import type { LookupString } from '@polkadot/types-codec/types';
import type { TypeDef } from '@polkadot/types-create/types';
import type { ModuleTypes, TypeImports } from './imports.js';
import Handlebars from 'handlebars';
@@ -12,7 +13,7 @@ import { getTypeDef, paramsNotation, TypeDefInfo } from '@polkadot/types-create'
import { isString, stringify } from '@polkadot/util';
import { readTemplate } from './file.js';
import { ModuleTypes, setImports, TypeImports } from './imports.js';
import { setImports } from './imports.js';
interface ImportDef {
file: string;