//#region src/tag.d.ts /** * Property key used to brand objects with a tag string. * * Defined via `Object.defineProperty` as non-enumerable, non-writable, and * non-configurable, so it does not appear in `Object.keys`, `JSON.stringify`, * `for...in`, or spread. */ declare const TAG: "__tag"; /** * Nominal type brand that carries a tag string on the {@link TAG} property. * * @private */ interface NominalTag { readonly [TAG]: TTag; } /** * Intersect a plain object type with a nominal tag brand. * * Used to brand plain data objects with a discriminator that is hidden from * enumeration, serialization, and spread — while remaining accessible via * the {@link TAG} key for runtime type-narrowing. */ type Tagged = TObj & NominalTag; /** * Create a shallow copy of `obj` with a non-enumerable {@link TAG} property. * * The original object is not mutated. The tag is defined as non-enumerable, * non-writable, and non-configurable via `Object.defineProperty`. * * @param obj - The source object to copy and tag. * @param tag - The tag string to brand the copy with. * @returns A new object with all own enumerable properties of `obj` plus the hidden tag. */ declare function withTag(obj: TObj, tag: TTag): Tagged; /** * Type guard that checks whether `value` carries the given tag. * * @param value - The value to inspect. * @param tag - The expected tag string. * @returns `true` when `value` is a non-null object whose `[TAG]` equals `tag`. */ declare function hasTag(value: unknown, tag: TTag): value is NominalTag; /** * Read the tag from a value, if present. * * @param value - The value to inspect. * @returns The tag string, or `undefined` when the value is untagged. */ declare function getTag(value: unknown): string | undefined; //#endregion export { TAG, Tagged, getTag, hasTag, withTag }; //# sourceMappingURL=tag.d.ts.map