Mark some function @internal (no doc extraction) (#1746)
This commit is contained in:
@@ -12,6 +12,7 @@ import { isUndefined } from '@polkadot/util';
|
||||
import { TYPES_CHAIN, TYPES_META, TYPES_MODULES, TYPES_SPEC } from './overrides';
|
||||
|
||||
// flatten a VersionedType[] into a Record<string, string>
|
||||
/** @internal */
|
||||
function filterVersions (versions: OverrideVersionedType[] = [], version: number): RegistryTypes {
|
||||
return versions
|
||||
.filter(({ minmax: [min, max] }): boolean =>
|
||||
@@ -25,11 +26,13 @@ function filterVersions (versions: OverrideVersionedType[] = [], version: number
|
||||
}
|
||||
|
||||
// based on the metadata version, return the registry types
|
||||
/** @internal */
|
||||
export function getMetadataTypes (version: number): RegistryTypes {
|
||||
return filterVersions(TYPES_META, version);
|
||||
}
|
||||
|
||||
// based on the chain and runtimeVersion, get the applicable types (ready for registration)
|
||||
/** @internal */
|
||||
export function getChainTypes (chainName: Text, { specName, specVersion }: RuntimeVersion, typesChain: Record<string, RegistryTypes> = {}, typesSpec: Record<string, RegistryTypes> = {}): RegistryTypes {
|
||||
const _chainName = chainName.toString();
|
||||
const _specName = specName.toString();
|
||||
@@ -44,6 +47,7 @@ export function getChainTypes (chainName: Text, { specName, specVersion }: Runti
|
||||
}
|
||||
|
||||
// get types for specific modules (metadata override)
|
||||
/** @internal */
|
||||
export function getModuleTypes (section: string): OverrideModuleType[] {
|
||||
return TYPES_MODULES[section] || [];
|
||||
}
|
||||
|
||||
@@ -25,14 +25,17 @@ const DESC_EVENTS = `\n\nEvents are emitted for certain operations on the runtim
|
||||
const DESC_RPC = '\n\nThe following sections contain RPC methods that are Remote Calls available by default and allow you to interact with the actual node, query, and submit.\n';
|
||||
const DESC_STORAGE = `\n\nThe following sections contain Storage methods are part of the default Substrate runtime. On the api, these are exposed via \`api.query.<module>.<method>\`. ${STATIC_TEXT}\n`;
|
||||
|
||||
/** @internal */
|
||||
function sectionLink (sectionName: string): string {
|
||||
return `- **[${stringCamelCase(sectionName)}](#${stringCamelCase(sectionName)})**\n\n`;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function generateSectionHeader (md: string, sectionName: string): string {
|
||||
return `${md}\n___\n${LINK_BACK_TO_TOP}\n\n## ${sectionName}\n`;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function addRpc (): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}JSON-RPC${DESC_RPC}\n`;
|
||||
const orderedSections = Object.keys(interfaces).sort();
|
||||
@@ -60,6 +63,7 @@ function addRpc (): string {
|
||||
/**
|
||||
* Sort object by their `.name`
|
||||
*/
|
||||
/** @internal */
|
||||
function sortByName<T extends { name: any }> (a: T, b: T): number {
|
||||
// ignore upper and lowercase
|
||||
const nameA = a.name.toString().toUpperCase();
|
||||
@@ -68,6 +72,7 @@ function sortByName<T extends { name: any }> (a: T, b: T): number {
|
||||
return nameA.localeCompare(nameB);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function addConstants (metadata: MetadataLatest): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Constants${DESC_CONSTANTS}`;
|
||||
const orderedSections = metadata.modules.sort(sortByName);
|
||||
@@ -96,6 +101,7 @@ function addConstants (metadata: MetadataLatest): string {
|
||||
return renderHeading + renderAnchors + sections;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function addEvents (metadata: MetadataLatest): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Events${DESC_EVENTS}`;
|
||||
const orderedSections = metadata.modules.sort(sortByName);
|
||||
@@ -126,6 +132,7 @@ function addEvents (metadata: MetadataLatest): string {
|
||||
return renderHeading + renderAnchors + sections;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function addExtrinsics (metadata: MetadataLatest): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Extrinsics${DESC_EXTRINSICS}`;
|
||||
const orderedSections = metadata.modules.map((i): ModuleMetadataLatest => i).sort(sortByName);
|
||||
@@ -156,6 +163,7 @@ function addExtrinsics (metadata: MetadataLatest): string {
|
||||
return renderHeading + renderAnchors + sections;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function addStorage (metadata: MetadataLatest): string {
|
||||
const renderHeading = `## ${ANCHOR_TOP}Storage${DESC_STORAGE}`;
|
||||
const orderedSections = metadata.modules.sort(sortByName);
|
||||
@@ -196,6 +204,7 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
return renderHeading + renderAnchors + sectionLink('substrate') + sections;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeFile (name: string, ...chunks: any[]): void {
|
||||
const options = { flags: 'w', encoding: 'utf8' };
|
||||
const writeStream = fs.createWriteStream(name, options);
|
||||
@@ -211,14 +220,17 @@ function writeFile (name: string, ...chunks: any[]): void {
|
||||
writeStream.end();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToRpcMd (): void {
|
||||
writeFile('docs/substrate/rpc.md', addRpc());
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToConstantsMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/constants.md', addConstants(metadata));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToStorageMd (metadata: MetadataLatest): void {
|
||||
const options = { flags: 'r', encoding: 'utf8' };
|
||||
const data = fs.readFileSync('docs/substrate/storage-known.md', options);
|
||||
@@ -226,10 +238,12 @@ function writeToStorageMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/storage.md', addStorage(metadata), data);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToExtrinsicsMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/extrinsics.md', addExtrinsics(metadata));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function writeToEventsMd (metadata: MetadataLatest): void {
|
||||
writeFile('docs/substrate/events.md', addEvents(metadata));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ const { argv: { ws } } = yargs
|
||||
}
|
||||
});
|
||||
|
||||
/** @internal */
|
||||
async function main (): Promise<void> {
|
||||
const provider = new WsProvider(ws);
|
||||
const api = await ApiPromise.create({ provider });
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Metadata, TypeRegistry } from '../..';
|
||||
import { createImportCode, createImports, FOOTER, HEADER, indent, setImports, TypeImports } from '../util';
|
||||
|
||||
// Generate types for one module
|
||||
/** @internal */
|
||||
function generateModule (modul: ModuleMetadataLatest, imports: TypeImports): string[] {
|
||||
if (!modul.constants.length) {
|
||||
return [];
|
||||
@@ -35,6 +36,7 @@ function generateModule (modul: ModuleMetadataLatest, imports: TypeImports): str
|
||||
|
||||
// Generate `packages/api/src/consts.types.ts` for a particular
|
||||
// metadata
|
||||
/** @internal */
|
||||
function generateForMeta (meta: Metadata): void {
|
||||
console.log('Writing packages/api/src/consts.types.ts');
|
||||
|
||||
@@ -84,6 +86,7 @@ function generateForMeta (meta: Metadata): void {
|
||||
}
|
||||
|
||||
// Call `generateForMeta()` with current static metadata
|
||||
/** @internal */
|
||||
export default function generateConsts (): void {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ const primitiveClasses = {
|
||||
Raw
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export function generateInterfaceRegistry (importDefinitions: { [importPath: string]: object }, output: string): void {
|
||||
console.log(`Writing ${output}`);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { TypeRegistry } from '../../codec';
|
||||
import { createImportCode, createImports, FOOTER, formatType, getSimilarTypes, HEADER, indent, setImports, TypeImports } from '../util';
|
||||
|
||||
// If the StorageEntry returns T, output `Option<T>` if the modifier is optional
|
||||
/** @internal */
|
||||
function addModifier (storageEntry: StorageEntryMetadataLatest, returnType: string): string {
|
||||
if (storageEntry.modifier.isOptional) {
|
||||
return `Option<${returnType}>`;
|
||||
@@ -24,6 +25,7 @@ function addModifier (storageEntry: StorageEntryMetadataLatest, returnType: stri
|
||||
}
|
||||
|
||||
// From a storage entry metadata, we return [args, returnType]
|
||||
/** @internal */
|
||||
function entrySignature (definitions: object, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [string, string] {
|
||||
if (storageEntry.type.isPlain) {
|
||||
setImports(definitions, imports, [storageEntry.type.asPlain.toString()]);
|
||||
@@ -66,6 +68,7 @@ function entrySignature (definitions: object, registry: Registry, storageEntry:
|
||||
}
|
||||
|
||||
// Generate types for one storage entry in a module
|
||||
/** @internal */
|
||||
function generateEntry (definitions: object, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): string[] {
|
||||
const [args, returnType] = entrySignature(definitions, registry, storageEntry, imports);
|
||||
|
||||
@@ -75,6 +78,7 @@ function generateEntry (definitions: object, registry: Registry, storageEntry: S
|
||||
}
|
||||
|
||||
// Generate types for one module
|
||||
/** @internal */
|
||||
function generateModule (definitions: object, registry: Registry, modul: ModuleMetadataLatest, imports: TypeImports): string[] {
|
||||
if (modul.storage.isNone) {
|
||||
return [];
|
||||
@@ -94,6 +98,7 @@ function generateModule (definitions: object, registry: Registry, modul: ModuleM
|
||||
|
||||
// Generate `packages/api/src/query.types.ts` for a particular
|
||||
// metadata
|
||||
/** @internal */
|
||||
function generateForMeta (definitions: object, registry: Registry, meta: Metadata): void {
|
||||
console.log('Writing packages/api/src/query.types.ts');
|
||||
|
||||
@@ -147,6 +152,7 @@ function generateForMeta (definitions: object, registry: Registry, meta: Metadat
|
||||
}
|
||||
|
||||
// Call `generateForMeta()` with current static metadata
|
||||
/** @internal */
|
||||
export default function generateQuery (): void {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { TypeRegistry } from '../../codec/create';
|
||||
import { createImportCode, createImports, FOOTER, getSimilarTypes, HEADER, setImports } from '../util';
|
||||
|
||||
// Generate `packages/rpc-core/jsonrpc.types.ts`
|
||||
/** @internal */
|
||||
export default function generateRpcTypes (): void {
|
||||
console.log('Writing packages/rpc-core/jsonrpc.types.ts');
|
||||
|
||||
|
||||
@@ -17,17 +17,20 @@ interface Imports extends TypeImports {
|
||||
}
|
||||
|
||||
// helper to generate a `readonly <Name>: <Type>;` getter
|
||||
/** @internal */
|
||||
export function createGetter (definitions: object, name = '', type: string, imports: TypeImports, doc?: string): string {
|
||||
setImports(definitions, imports, [type]);
|
||||
|
||||
return ` /** ${doc || type} */\n readonly ${name}: ${type};\n`;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function errorUnhandled (definitions: object, def: TypeDef, imports: TypeImports): string {
|
||||
throw new Error(`Generate: ${name}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsExport (definitions: object, def: TypeDef, imports: TypeImports): string {
|
||||
return exportInterface(def.name, formatType(definitions, def, imports));
|
||||
}
|
||||
@@ -39,6 +42,7 @@ const tsOption = tsExport;
|
||||
const tsPlain = tsExport;
|
||||
const tsTuple = tsExport;
|
||||
|
||||
/** @internal */
|
||||
function tsEnum (definitions: object, { name: enumName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(definitions, imports, ['Enum']);
|
||||
|
||||
@@ -62,6 +66,7 @@ function tsEnum (definitions: object, { name: enumName, sub }: TypeDef, imports:
|
||||
return exportInterface(enumName, 'Enum', keys.join(''));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsResultGetter (definitions: object, resultName = '', getter: 'Ok' | 'Error', def: TypeDef, imports: TypeImports): string {
|
||||
const { info, name = '', type } = def;
|
||||
const [resultType, asGetter] = type === 'Null'
|
||||
@@ -80,6 +85,7 @@ function tsResultGetter (definitions: object, resultName = '', getter: 'Ok' | 'E
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsResult (definitions: object, def: TypeDef, imports: TypeImports): string {
|
||||
const [okDef, errorDef] = (def.sub as TypeDef[]);
|
||||
const inner = [
|
||||
@@ -92,6 +98,7 @@ function tsResult (definitions: object, def: TypeDef, imports: TypeImports): str
|
||||
return exportInterface(def.name, formatType(definitions, def, imports), inner);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsSet (definitions: object, { name: setName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(definitions, imports, ['Set']);
|
||||
|
||||
@@ -102,6 +109,7 @@ function tsSet (definitions: object, { name: setName, sub }: TypeDef, imports: T
|
||||
return exportInterface(setName, 'Set', types.join(''));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsStruct (definitions: object, { name: structName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(definitions, imports, ['Struct']);
|
||||
|
||||
@@ -114,6 +122,7 @@ function tsStruct (definitions: object, { name: structName, sub }: TypeDef, impo
|
||||
return exportInterface(structName, 'Struct', keys.join(''));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsVec (definitions: object, def: TypeDef, imports: TypeImports): string {
|
||||
const type = def.info === TypeDefInfo.VecFixed
|
||||
? (def.ext as TypeDefExtVecFixed).type
|
||||
@@ -130,6 +139,7 @@ function tsVec (definitions: object, def: TypeDef, imports: TypeImports): string
|
||||
return exportInterface(def.name, formatType(definitions, def, imports));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function generateInterfaces (definitions: object, { types }: { types: Record<string, any> }, imports: Imports): [string, string][] {
|
||||
// handlers are defined externally to use - this means that when we do a
|
||||
// `generators[typedef.info](...)` TS will show any unhandled types. Rather
|
||||
@@ -158,6 +168,7 @@ function generateInterfaces (definitions: object, { types }: { types: Record<str
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function generateTsDefFor (importDefinitions: { [importPath: string]: object }, defName: string, { types }: { types: Record<string, any> }, outputDir: string): void {
|
||||
const imports = { ...createImports(importDefinitions, { types }), interfaces: [] } as Imports;
|
||||
const definitions = imports.definitions;
|
||||
@@ -195,6 +206,7 @@ function generateTsDefFor (importDefinitions: { [importPath: string]: object },
|
||||
fs.writeFileSync(path.join(outputDir, defName, 'index.ts'), HEADER.concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function generateTsDef (importDefinitions: { [importPath: string]: object }, outputDir: string, generatingPackage: string): void {
|
||||
const definitions = importDefinitions[generatingPackage];
|
||||
Object.entries(definitions).forEach(([defName, obj]): void => {
|
||||
@@ -209,6 +221,7 @@ export function generateTsDef (importDefinitions: { [importPath: string]: object
|
||||
fs.writeFileSync(path.join(outputDir, 'index.ts'), HEADER.concat('export * from \'./types\';').concat(FOOTER), { flag: 'w' });
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export default function generateTsDefDefault (): void {
|
||||
generateTsDef(
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ import generateQueryTypes from './generateTypes/query';
|
||||
import generateRpcTypes from './generateTypes/rpc';
|
||||
import generateTsDef from './generateTypes/tsDef';
|
||||
|
||||
/** @internal */
|
||||
function main (): void {
|
||||
generateConstsTypes();
|
||||
generateInterfaceRegistry();
|
||||
|
||||
@@ -8,12 +8,14 @@ import UInt from '../../codec/UInt';
|
||||
|
||||
// See if a class is child of another class
|
||||
// FIMXE This could go in util some day
|
||||
/** @internal */
|
||||
export function isChildClass (Parent: Constructor<any>, Child: Constructor<any>): boolean {
|
||||
// https://stackoverflow.com/questions/30993434/check-if-a-constructor-inherits-another-in-es6/30993664
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
return Parent === Child || Parent.isPrototypeOf(Child);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isCompactEncodable (Child: Constructor<any>): boolean {
|
||||
return isChildClass(UInt, Child);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { setImports, TypeImports } from './imports';
|
||||
import * as primitiveClasses from '../../primitive';
|
||||
|
||||
// From `T`, generate `Compact<T>, Option<T>, Vec<T>`
|
||||
/** @internal */
|
||||
export function getDerivedTypes (definitions: object, type: string, primitiveName: string, imports: TypeImports): string[] {
|
||||
// `primitiveName` represents the actual primitive type our type is mapped to
|
||||
const isCompact = isCompactEncodable((primitiveClasses as any)[primitiveName]);
|
||||
@@ -50,6 +51,7 @@ export function getDerivedTypes (definitions: object, type: string, primitiveNam
|
||||
// Make types a little bit more flexible
|
||||
// - if param instanceof AbstractInt, then param: u64 | Uint8array | string | number
|
||||
// etc
|
||||
/** @internal */
|
||||
export function getSimilarTypes (definitions: object, registry: Registry, type: string, imports: TypeImports): string[] {
|
||||
const possibleTypes = [type];
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ export const HEADER = '// Auto-generated via `yarn build:interfaces`, do not edi
|
||||
export const FOOTER = '\n';
|
||||
|
||||
// creates the import lines
|
||||
/** @internal */
|
||||
export function createImportCode (header: string, checks: { file: string; types: string[] }[]): string {
|
||||
return checks.reduce((result, { file, types }): string => {
|
||||
if (types.length) {
|
||||
@@ -23,6 +24,7 @@ export function createImportCode (header: string, checks: { file: string; types:
|
||||
}
|
||||
|
||||
// helper to generate a `export interface <Name> extends <Base> {<Body>}
|
||||
/** @internal */
|
||||
export function exportInterface (name = '', base: string, body = ''): string {
|
||||
return `/** ${base} */\nexport interface ${name} extends ${base} {${body.length ? '\n' : ''}${body}}`;
|
||||
}
|
||||
@@ -30,6 +32,7 @@ export function exportInterface (name = '', base: string, body = ''): string {
|
||||
// helper to create an `export type <Name> = <Base>`
|
||||
// but since we don't want type alias (TS doesn't preserve names) we use
|
||||
// interface here.
|
||||
/** @internal */
|
||||
export function exportType (name = '', base: string): string {
|
||||
return exportInterface(name, base);
|
||||
}
|
||||
@@ -37,6 +40,7 @@ export function exportType (name = '', base: string): string {
|
||||
/**
|
||||
* Given the inner `K` & `V`, return a `BTreeMap<K, V>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatBTreeMap (key: string, val: string): string {
|
||||
return `BTreeMap<${key}, ${val}>`;
|
||||
}
|
||||
@@ -44,6 +48,7 @@ function formatBTreeMap (key: string, val: string): string {
|
||||
/**
|
||||
* Given the inner `V`, return a `BTreeSet<V>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatBTreeSet (val: string): string {
|
||||
return `BTreeSet<${val}>`;
|
||||
}
|
||||
@@ -51,6 +56,7 @@ function formatBTreeSet (val: string): string {
|
||||
/**
|
||||
* Given the inner `T`, return a `Compact<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatCompact (inner: string): string {
|
||||
return paramsNotation('Compact', inner);
|
||||
}
|
||||
@@ -58,6 +64,7 @@ function formatCompact (inner: string): string {
|
||||
/**
|
||||
* Given the inner `O` & `E`, return a `Result<O, E>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatResult (innerOk: string, innerError: string): string {
|
||||
return `Result<${innerOk}, ${innerError}>`;
|
||||
}
|
||||
@@ -65,6 +72,7 @@ function formatResult (innerOk: string, innerError: string): string {
|
||||
/**
|
||||
* Given the inner `T`, return a `Option<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatOption (inner: string): string {
|
||||
return paramsNotation('Option', inner);
|
||||
}
|
||||
@@ -72,6 +80,7 @@ function formatOption (inner: string): string {
|
||||
/**
|
||||
* Given the inners `T[]`, return a `ITuple<...T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatTuple (inners: string[]): string {
|
||||
return paramsNotation('ITuple', `[${inners.join(', ')}]`);
|
||||
}
|
||||
@@ -79,6 +88,7 @@ function formatTuple (inners: string[]): string {
|
||||
/**
|
||||
* Given the inner `T`, return a `Vec<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatVec (inner: string): string {
|
||||
return paramsNotation('Vec', inner);
|
||||
}
|
||||
@@ -86,6 +96,7 @@ function formatVec (inner: string): string {
|
||||
/**
|
||||
* Correctly format a given type
|
||||
*/
|
||||
/** @internal */
|
||||
export function formatType (definitions: object, type: string | TypeDef, imports: TypeImports): string {
|
||||
let typeDef: TypeDef;
|
||||
if (typeof type === 'string') {
|
||||
@@ -155,6 +166,7 @@ export function formatType (definitions: object, type: string | TypeDef, imports
|
||||
/**
|
||||
* Indent a string with `n` spaces before.
|
||||
*/
|
||||
/** @internal */
|
||||
export function indent (n: number, char = ' '): (str: string) => string {
|
||||
return function (str: string): string {
|
||||
return `${char.repeat(n)}${str}`;
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface TypeImports {
|
||||
|
||||
// Maps the types as found to the source location. This is used to generate the
|
||||
// imports in the output file, dep-duped and sorted
|
||||
/** @internal */
|
||||
export function setImports (definitions: object, imports: TypeImports, types: string[]): void {
|
||||
const { codecTypes, localTypes, ignoredTypes, primitiveTypes, typesTypes } = imports;
|
||||
|
||||
@@ -67,6 +68,7 @@ export function setImports (definitions: object, imports: TypeImports, types: st
|
||||
}
|
||||
|
||||
// Create an Imports object, can be prefilled with `ignoredTypes`
|
||||
/** @internal */
|
||||
export function createImports (importDefinitions: { [importPath: string]: object }, { types }: { types: Record<string, any> } = { types: {} }): TypeImports {
|
||||
const definitions = {} as Record<string, object>;
|
||||
const typeToModule = {} as Record<string, string>;
|
||||
|
||||
Reference in New Issue
Block a user