Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Param ({ className, defaultValue, isDisabled, isOptional, name, onChange, onEnter, onEscape, overrides, style, type }: Props): React.ReactElement | null {
const compRef = useRef | null>(findComponent(type, overrides));
if (!compRef.current) {
return null;
}
const label = isUndefined(name)
? displayType(type)
: `${name}: ${displayType(type)}`;
return isOptional
? (
)
: (
{args.map(({ name, type }, index): React.ReactNode => {
return (
{name}:
{' '}
{params && params[index]
? (
<b>
{truncate(params[index].toString())}
</b>
)
: displayType(type)}
{index < args.length - 1 && ', '}
);
})}
)
{truncate(params[index].toString())}
)
: displayType(type)}
{index < args.length - 1 && ', '}
);
})}
)
{(!asConstructor && returnType) && (
<>
:
{' '}
{displayType(returnType)}
)}
{mutates && (
<>
{withTooltip && (
private typeDefForBuiltinVecFixed (id: MetaTypeIdVecFixed, typeIndex?: TypeIndex): Pick {
const { 'array.type': vecTypeIndex, 'array.len': vecLength } = id;
assert(!vecLength || vecLength <= 256, 'MetaRegistry: Only support for [Type; ], where length <= 256');
assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);
const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
assert(type && type.length > 0, `MetaRegistry: Invalid vector type found at index ${typeIndex}`);
return {
info: TypeDefInfo.VecFixed,
ext: { length: vecLength, type },
type: `[${type};${vecLength}]`,
sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
};
}
function Param ({ className, defaultValue, isDisabled, isOptional, name, onChange, onEnter, onEscape, overrides, style, type }: Props): React.ReactElement | null {
const compRef = useRef | null>(findComponent(type, overrides));
if (!compRef.current) {
return null;
}
const label = isUndefined(name)
? displayType(type)
: `${name}: ${displayType(type)}`;
return isOptional
? (
)
: (
private typeDefForBuiltinVec (id: MetaTypeIdVec, typeIndex?: TypeIndex): Pick {
const { 'slice.type': vecTypeIndex } = id;
assert(!typeIndex || vecTypeIndex !== typeIndex, `MetaRegistry: self-referencing registry type at index ${typeIndex}`);
const type = displayType(this.typeDefFromMetaTypeAt(vecTypeIndex));
assert(type && type.length > 0, `MetaRegistry: Invalid builtin Vec type found at index ${typeIndex}`);
return {
info: TypeDefInfo.Vec,
type: `Vec<${type}>`,
sub: this.typeDefFromMetaTypeAt(vecTypeIndex)
};
}