packages/types/src/create/createType.ts
// Copyright 2017-2024 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Codec, Registry } from '@polkadot/types-codec/types';
import type { DetectCodec } from '../types/index.js';
import { createTypeUnsafe } from '@polkadot/types-create';
/**
* Create an instance of a `type` with a given `params`.
* @param type - A recognizable string representing the type to create an
* instance from
* @param params - The value to instantiate the type with
*/
export function createType<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, ...params: unknown[]): DetectCodec<T, K> {
return createTypeUnsafe(registry, type, params);
}