@typespec/compiler
Version:
TypeSpec compiler and standard library
58 lines • 1.45 kB
TypeScript
import type { Entity, Type, Union, UnionVariant } from "../../core/types.js";
import { DecoratorArgs } from "../utils.js";
/**
* A descriptor for a union variant.
*/
export interface UnionVariantDescriptor {
/**
* The name of the union variant.
*/
name?: string | symbol;
/**
* Decorators to apply to the union variant.
*/
decorators?: DecoratorArgs[];
/**
* The type of the union variant.
*/
type: Type;
/**
* The union that the variant belongs to. If not provided here, it is assumed
* that it will be set in `union.build`.
*/
union?: Union;
}
/**
* Utilities for working with union variants.
*
* Union variants are types that represent a single value within a union that can be one of
* several types.
*
* @typekit unionVariant
*/
export interface UnionVariantKit {
/**
* Create a union variant.
*
* @param desc The descriptor of the union variant.
*/
create(desc: UnionVariantDescriptor): UnionVariant;
/**
* Check if the given `type` is a union.
*
* @param type The type to check.
*/
is(type: Entity): type is UnionVariant;
}
interface TypekitExtension {
/**
* Utilities for working with union variants.
*/
unionVariant: UnionVariantKit;
}
declare module "../define-kit.js" {
interface Typekit extends TypekitExtension {
}
}
export {};
//# sourceMappingURL=union-variant.d.ts.map