@rbxts/flamework-meta-utils
Version:
Metadata utility and utility macros for Flamework
31 lines (30 loc) • 1.66 kB
TypeScript
import type { Modding } from "@flamework/core";
import type { t } from "@rbxts/t";
import type { String, List } from "ts-toolbelt";
/** @metadata macro */
export declare function identity<T>(meta?: Modding.Many<T>): T;
/** @metadata macro {@link meta intrinsic-inline} */
export declare function enumKey<E, V>(meta?: Modding.Many<{
[K in keyof E]: E[K] extends V ? K : never;
}[keyof E]>): string;
/** @metadata macro */
export declare function deunify<T>(result?: Modding.Many<T[]>): T[];
/** @metadata macro {@link result intrinsic-inline} */
export declare function repeatString<S extends string, N extends number>(s?: S | Modding.Many<S>, n?: N | Modding.Many<N>, result?: Modding.Many<String.Join<List.Repeat<S, N>>>): string;
/** @metadata macro */
export declare function getChildrenOfType<T extends Instance>(instance: Instance, guard?: t.check<T> | Modding.Generic<T, "guard">): T[];
/** @metadata macro */
export declare function getDescendantsOfType<T extends Instance>(instance: Instance, guard?: t.check<T> | Modding.Generic<T, "guard">): T[];
/**
* Resolves the instance at the given path using Rojo
*
* @metadata macro intrinsic-arg-shift {@link _getInstanceAtPath intrinsic-flamework-rewrite}
*/
export declare function getInstanceAtPath<Path extends string>(path: Path, _meta?: Modding.Intrinsic<"path", [Path]>): Instance | undefined;
/**
* Macro that generates a type guard (if one is not specified) and if the guard passes, returns the casted value.
* Otherwise returns undefined.
*
* @metadata macro
*/
export declare function safeCast<T>(value: unknown, guard?: t.check<T> | Modding.Generic<T, "guard">): T | undefined;