[API] Typekits
array
Typekits for working with array types(Model with number indexer).
create
/** * Create an array type. */$(program).array.create(elementType: Type): ArrayModelType;
getElementType
/** * Get the element type of an array. */$(program).array.getElementType(type: Model): Type;
is
/** * Check if a type is an array. */$(program).array.is(type: Entity): type is ArrayModelType;
builtin
A kit of built-in types.
boolean
/** * Accessor for the boolean builtin type. */$(program).builtin.boolean: Scalar;
bytes
/** * Accessor for the bytes builtin type, representing binary data. */$(program).builtin.bytes: Scalar;
decimal
/** * Accessor for the decimal builtin type for high-precision decimal values. */$(program).builtin.decimal: Scalar;
decimal128
/** * Accessor for the decimal128 builtin type, a 128-bit decimal value. */$(program).builtin.decimal128: Scalar;
duration
/** * Accessor for the duration builtin type, representing a span of time. */$(program).builtin.duration: Scalar;
float
/** * Accessor for the float builtin type, representing a double-precision floating-point number. */$(program).builtin.float: Scalar;
float32
/** * Accessor for the float32 builtin type, representing a single-precision floating-point number. */$(program).builtin.float32: Scalar;
float64
/** * Accessor for the float64 builtin type, representing a double-precision floating-point number. */$(program).builtin.float64: Scalar;
int16
/** * Accessor for the int16 builtin type, representing a 16-bit signed integer. */$(program).builtin.int16: Scalar;
int32
/** * Accessor for the int32 builtin type, representing a 32-bit signed integer. */$(program).builtin.int32: Scalar;
int64
/** * Accessor for the int64 builtin type, representing a 64-bit signed integer. */$(program).builtin.int64: Scalar;
int8
/** * Accessor for the int8 builtin type, representing an 8-bit signed integer. */$(program).builtin.int8: Scalar;
integer
/** * Accessor for the integer builtin type, representing an arbitrary-precision integer. */$(program).builtin.integer: Scalar;
numeric
/** * Accessor for the numeric builtin type, representing a numeric value. */$(program).builtin.numeric: Scalar;
offsetDateTime
/** * Accessor for the offsetDateTime builtin type, representing a date and time with an offset. */$(program).builtin.offsetDateTime: Scalar;
plainDate
/** * Accessor for the plainDate builtin type, representing a date without time or offset. */$(program).builtin.plainDate: Scalar;
plainTime
/** * Accessor for the plainTime builtin type, representing a time without date or offset. */$(program).builtin.plainTime: Scalar;
safeInt
/** * Accessor for the safeInt builtin type, representing an integer within the safe range for JavaScript. */$(program).builtin.safeInt: Scalar;
string
/** * Accessor for the string builtin type. */$(program).builtin.string: Scalar;
uint16
/** * Accessor for the uint16 builtin type, representing a 16-bit unsigned integer. */$(program).builtin.uint16: Scalar;
uint32
/** * Accessor for the uint32 builtin type, representing a 32-bit unsigned integer. */$(program).builtin.uint32: Scalar;
uint64
/** * Accessor for the uint64 builtin type, representing a 64-bit unsigned integer. */$(program).builtin.uint64: Scalar;
uint8
/** * Accessor for the uint8 builtin type, representing an 8-bit unsigned integer. */$(program).builtin.uint8: Scalar;
url
/** * Accessor for the url builtin type, representing a valid URL string. */$(program).builtin.url: Scalar;
utcDateTime
/** * Accessor for the utcDateTime builtin type, representing a date and time in UTC. */$(program).builtin.utcDateTime: Scalar;
entity
Typekits for working with the top level entity.
isAssignableTo Diagnosable
/** * Check if the source type can be assigned to the target. * * @param source - Source type * * @param target - Target type * * @param diagnosticTarget - Target for the diagnostic */$(program).entity .isAssignableTo(source: Entity, target: Entity, diagnosticTarget?: Entity | Node): boolean;$(program).entity.isAssignableTo .withDiagnostics(source: Entity, target: Entity, diagnosticTarget?: Entity | Node): [boolean, readonly Diagnostic[]];
resolve Diagnosable
/** * Resolve a type reference string to a TypeSpec type. By default any diagnostics are ignored. * * Call `resolve.withDiagnostics("Type")` to get a tuple containing the resolved type and any diagnostics. */$(program).entity.resolve(): reference: stringEntity | undefined;$(program).entity.resolve .withDiagnostics(): [reference: stringEntity | undefined, readonly Diagnostic[]];
enum
A kit for working with enum types.
create
/** * Build an enum type. The enum type will be finished (i.e. decorators are run). */$(program).enum.create(desc: EnumDescriptor): Enum;
createFromUnion
/** * Build an equivalent enum from the given union. * * @remarks * * Union variants which are not valid enum members are skipped. You can check if a union is a valid enum with {@link UnionKit.union}'s `isEnumValue`. * * Any API documentation will be rendered and preserved in the resulting enum. - No other decorators are copied from the union to the enum */$(program).enum.createFromUnion(type: Union): Enum;
is
/** * Check if `type` is an enum type. * * @param type - the type to check. */$(program).enum.is(type: Entity): type is Enum;
enumMember
A kit for working with enum members.
create
/** * Create an enum member. The enum member will be finished (i.e. decorators are run). */$(program).enumMember.create(desc: EnumMemberDescriptor): EnumMember;
is
/** * Check if `type` is an enum member type. * * @param type - the type to check. */$(program).enumMember.is(type: Entity): type is EnumMember;
intrinsic
any
/** * The intrinsic 'any' type. */$(program).intrinsic.any: UnknownType;
error
/** * The intrinsic 'error' type. */$(program).intrinsic.error: ErrorType;
is
/** * Check if `entity` is an intrinsic type. * * @param entity - The `entity` to check. */$(program).intrinsic.is(entity: Entity): entity is IntrinsicType;
never
/** * The intrinsic 'never' type. */$(program).intrinsic.never: NeverType;
null
/** * The intrinsic 'null' type. */$(program).intrinsic.null: NullType;
void
/** * The intrinsic 'void' type. */$(program).intrinsic.void: VoidType;
literal
A Typekit for working with literal types(string, numeric, boolean).
create
/** * Create a literal type from a JavaScript value. * * @param value - The JavaScript value to turn into a TypeSpec literal type. */$(program).literal .create(value: string | number | boolean): StringLiteral | NumericLiteral | BooleanLiteral;
createBoolean
/** * Create a boolean literal type from a JavaScript boolean value. * * @param value - The boolean value. */$(program).literal.createBoolean(value: boolean): BooleanLiteral;
createNumeric
/** * Create a numeric literal type from a JavaScript number value. * * @param value - The numeric value. */$(program).literal.createNumeric(value: number): NumericLiteral;
createString
/** * Create a string literal type from a JavaScript string value. * * @param value - The string value. */$(program).literal.createString(value: string): StringLiteral;
is
/** * Check if `type` is a literal type. * * @param type - The type to check. */$(program).literal .is(type: Entity): type is StringLiteral | NumericLiteral | BooleanLiteral;
isBoolean
/** * Check if `type` is a boolean literal type. * * @param type - The type to check. */$(program).literal.isBoolean(type: Entity): type is BooleanLiteral;
isNumeric
/** * Check if `type` is a numeric literal type. * * @param type - The type to check. */$(program).literal.isNumeric(type: Entity): type is NumericLiteral;
isString
/** * Check if `type` is a string literal type. * * @param type - The type to check. */$(program).literal.isString(type: Entity): type is StringLiteral;
model
Utilities for working with models.
create
/** * Create a model type. * * @param desc - The descriptor of the model. */$(program).model.create(desc: ModelDescriptor): Model;
getAdditionalPropertiesRecord
/** * Get the record representing additional properties, if there are additional properties. This method checks for additional properties in the following cases: 1. If the model is a Record type. 2. If the model extends a Record type. 3. If the model spreads a Record type. * * @param model - The model to get the additional properties type of. * * @returns The record representing additional properties, or undefined if there are none. */$(program).model.getAdditionalPropertiesRecord(model: Model): Model | undefined;
getDiscriminatedUnion Diagnosable
/** * Resolves a discriminated union for the given model from inheritance. * * @param type - Model to resolve the discriminated union for. */$(program).model .getDiscriminatedUnion(model: Model): DiscriminatedUnionLegacy | undefined;$(program).model.getDiscriminatedUnion .withDiagnostics(model: Model): [DiscriminatedUnionLegacy | undefined, readonly Diagnostic[]];
getEffectiveModel
/** * If the input is anonymous (or the provided filter removes properties) and there exists a named model with the same set of properties (ignoring filtered properties), then return that named model. Otherwise, return the input unchanged. * * This can be used by emitters to find a better name for a set of properties after filtering. For example, given `{ @metadata prop: string} & SomeName`, and an emitter that wishes to discard properties marked with `@metadata`, the emitter can use this to recover that the best name for the remaining properties is `SomeName`. * * @param model - The input model * * @param filter - An optional filter to apply to the input model's properties. */$(program).model.getEffectiveModel(model: Model,filter: (property: ModelProperty) => boolean): Model;
getProperties
/** * Gets all properties from a model, explicitly defined and implicitly defined. * * @param model - model to get the properties from */$(program).model.getProperties(model: Model,options: { includeExtended?: boolean; }): RekeyableMap<string, ModelProperty>;
is
/** * Check if the given `type` is a model.. * * @param type - The type to check. */$(program).model.is(type: Entity): type is Model;
isExpresion
/** * Check this is an anonyous model. Specifically, this checks if the model has a name. * * @param type - The model to check. */$(program).model.isExpresion(type: Model): boolean;
modelProperty
Utilities for working with model properties.
For many reflection operations, the metadata being asked for may be found on the model property or the type of the model property. In such cases, these operations will return the metadata from the model property if it exists, or the type of the model property if it exists.
create
/** * Creates a modelProperty type. * * @param desc - The descriptor of the model property. */$(program).modelProperty.create(desc: ModelPropertyDescriptor): ModelProperty;
getEncoding
/** * Get the encoding of the model property or its type. The property's type must be a scalar. * * @param property - The model property to get the encoding for. */$(program).modelProperty .getEncoding(property: ModelProperty): EncodeData | undefined;
getFormat
/** * Get the format of the model property or its type. The property's type must be a string. * * @param property - The model property to get the format for. */$(program).modelProperty.getFormat(property: ModelProperty): string | undefined;
getVisibilityForClass
/** * Get the visibility of the model property. */$(program).modelProperty.getVisibilityForClass(property: ModelProperty,visibilityClass: Enum): Set<EnumMember>;
is
/** * Check if the given `type` is a model property. * * @param type - The type to check. */$(program).modelProperty.is(type: Entity): type is ModelProperty;
operation
Utilities for working with operation properties.
create
/** * Create an operation type. * * @param desc - The descriptor of the operation. */$(program).operation.create(desc: OperationDescriptor): Operation;
getPagingMetadata Diagnosable
/** * Get the paging operation's metadata for an operation. * * @param operation - operation to get the paging operation for */$(program).operation .getPagingMetadata(operation: Operation): PagingOperation | undefined;$(program).operation.getPagingMetadata .withDiagnostics(operation: Operation): [PagingOperation | undefined, readonly Diagnostic[]];
is
/** * Check if the type is an operation. * * @param type - type to check */$(program).operation.is(type: Entity): type is Operation;
record
RecordKit provides utilities for working with Record Model types.
create
/** * Create a Record Model type * * @param elementType - The type of the elements in the record */$(program).record.create(elementType: Type): RecordModelType;
getElementType
/** * Get the element type of a Record * * @param type - a Record Model type */$(program).record.getElementType(type: Model): Type;
is
/** * Check if the given `type` is a Record. * * @param type - The type to check. */$(program).record.is(type: Entity): type is RecordModelType;
scalar
Operations for scalar types like strings, numerics, booleans, dates, etc.
extendsBoolean
/** * Check if `type` extends the standard boolean type. * * @param type - The type to check. */$(program).scalar.extendsBoolean(type: Entity): type is Scalar;
extendsBytes
/** * Check if `type` extends the standard bytes type. * * @param type - The type to check. */$(program).scalar.extendsBytes(type: Entity): type is Scalar;
extendsDecimal
/** * Check if `type` extends the standard decimal type. * * @param type - The type to check. */$(program).scalar.extendsDecimal(type: Entity): type is Scalar;
extendsDecimal128
/** * Check if `type` extends the standard decimal128 type. * * @param type - The type to check. */$(program).scalar.extendsDecimal128(type: Entity): type is Scalar;
extendsDuration
/** * Check if `type` extends the standard duration type. * * @param type - The type to check. */$(program).scalar.extendsDuration(type: Entity): type is Scalar;
extendsFloat
/** * Check if `type` extends the standard float type. * * @param type - The type to check. */$(program).scalar.extendsFloat(type: Entity): type is Scalar;
extendsFloat32
/** * Check if `type` extends the standard float32 type. * * @param type - The type to check. */$(program).scalar.extendsFloat32(type: Entity): type is Scalar;
extendsFloat64
/** * Check if `type` extends the standard float64 type. * * @param type - The type to check. */$(program).scalar.extendsFloat64(type: Entity): type is Scalar;
extendsInt16
/** * Check if `type` extends the standard int16 type. * * @param type - The type to check. */$(program).scalar.extendsInt16(type: Entity): type is Scalar;
extendsInt32
/** * Check if `type` extends the standard int32 type. * * @param type - The type to check. */$(program).scalar.extendsInt32(type: Entity): type is Scalar;
extendsInt64
/** * Check if `type` extends the standard int64 type. * * @param type - The type to check. */$(program).scalar.extendsInt64(type: Entity): type is Scalar;
extendsInt8
/** * Check if `type` extends the standard int8 type. * * @param type - The type to check. */$(program).scalar.extendsInt8(type: Entity): type is Scalar;
extendsInteger
/** * Check if `type` extends the standard integer type. * * @param type - The type to check. */$(program).scalar.extendsInteger(type: Entity): type is Scalar;
extendsNumeric
/** * Check if `type` extends the standard numeric type. * * @param type - The type to check. */$(program).scalar.extendsNumeric(type: Entity): type is Scalar;
extendsOffsetDateTime
/** * Check if `type` extends the standard offsetDateTime type. * * @param type - The type to check. */$(program).scalar.extendsOffsetDateTime(type: Entity): type is Scalar;
extendsPlainDate
/** * Check if `type` extends the standard plainDate type. * * @param type - The type to check. */$(program).scalar.extendsPlainDate(type: Entity): type is Scalar;
extendsPlainTime
/** * Check if `type` extends the standard plainTime type. * * @param type - The type to check. */$(program).scalar.extendsPlainTime(type: Entity): type is Scalar;
extendsSafeint
/** * Check if `type` extends the standard safeint type. * * @param type - The type to check. */$(program).scalar.extendsSafeint(type: Entity): type is Scalar;
extendsString
/** * Check if `type` extends the standard string type. * * @param type - The type to check. */$(program).scalar.extendsString(type: Entity): type is Scalar;
extendsUint16
/** * Check if `type` extends the standard uint16 type. * * @param type - The type to check. */$(program).scalar.extendsUint16(type: Entity): type is Scalar;
extendsUint32
/** * Check if `type` extends the standard uint32 type. * * @param type - The type to check. */$(program).scalar.extendsUint32(type: Entity): type is Scalar;
extendsUint64
/** * Check if `type` extends the standard uint64 type. * * @param type - The type to check. */$(program).scalar.extendsUint64(type: Entity): type is Scalar;
extendsUint8
/** * Check if `type` extends the standard uint8 type. * * @param type - The type to check. */$(program).scalar.extendsUint8(type: Entity): type is Scalar;
extendsUrl
/** * Check if `type` extends the standard url type. * * @param type - The type to check. */$(program).scalar.extendsUrl(type: Entity): type is Scalar;
extendsUtcDateTime
/** * Check if `type` extends the standard utcDateTime type. * * @param type - The type to check. */$(program).scalar.extendsUtcDateTime(type: Entity): type is Scalar;
getEncoding
/** * Get the encoding information for a scalar type. Returns undefined if no encoding data is specified. * * Note: This will return the encoding data for the scalar type itself, not the model property that uses the scalar type. If this scalar might be referenced from a model property, use {@link modelProperty.getEncoding} instead. * * @param scalar - The scalar to get the encoding data for. */$(program).scalar.getEncoding(scalar: Scalar): EncodeData | undefined;
getFormat
/** * Get the well-known format for a string scalar. Returns undefined if no format is specified. * * Note: This will return the format data for the scalar type itself, not the model property that uses the scalar type. If this scalar might be referenced from a model property, use {@link ModelPropertyKit.getEncoding} instead. * * @param scalar - The scalar to get the format for. */$(program).scalar.getFormat(scalar: Scalar): string | undefined;
getStdBase
/** * Get the standard built-in base type of a scalar. For all built-in scalar types (numeric, string, int32, etc.) this will just return the scalar type. For user-defined scalars, this will return the first base scalar that is built-in. For user-defined scalars without a standard base type, this will return null. * * @param type - The scalar to check. */$(program).scalar.getStdBase(type: Scalar): Scalar | null;
is
/** * Check if `type` is any scalar type. * * @param type - The type to check. */$(program).scalar.is(type: Entity): type is Scalar;
isBoolean
/** * Check if `type` is exactly the standard boolean type. * * @param type - The type to check. */$(program).scalar.isBoolean(type: Entity): type is Scalar;
isBytes
/** * Check if `type` is exactly the standard bytes type. * * @param type - The type to check. */$(program).scalar.isBytes(type: Entity): type is Scalar;
isDecimal
/** * Check if `type` is exactly the standard decimal type. * * @param type - The type to check. */$(program).scalar.isDecimal(type: Entity): type is Scalar;
isDecimal128
/** * Check if `type` is exactly the standard decimal128 type. * * @param type - The type to check. */$(program).scalar.isDecimal128(type: Entity): type is Scalar;
isDuration
/** * Check if `type` is exactly the standard duration type. * * @param type - The type to check. */$(program).scalar.isDuration(type: Entity): type is Scalar;
isFloat
/** * Check if `type` is exactly the standard float type. * * @param type - The type to check. */$(program).scalar.isFloat(type: Entity): type is Scalar;
isFloat32
/** * Check if `type` is exactly the standard float32 type. * * @param type - The type to check. */$(program).scalar.isFloat32(type: Entity): type is Scalar;
isFloat64
/** * Check if `type` is exactly the standard float64 type. * * @param type - The type to check. */$(program).scalar.isFloat64(type: Entity): type is Scalar;
isInt16
/** * Check if `type` is exactly the standard int16 type. * * @param type - The type to check. */$(program).scalar.isInt16(type: Entity): type is Scalar;
isInt32
/** * Check if `type` is exactly the standard int32 type. * * @param type - The type to check. */$(program).scalar.isInt32(type: Entity): type is Scalar;
isInt64
/** * Check if `type` is exactly the standard int64 type. * * @param type - The type to check. */$(program).scalar.isInt64(type: Entity): type is Scalar;
isInt8
/** * Check if `type` is exactly the standard int8 type. * * @param type - The type to check. */$(program).scalar.isInt8(type: Entity): type is Scalar;
isInteger
/** * Check if `type` is exactly the standard integer type. * * @param type - The type to check. */$(program).scalar.isInteger(type: Entity): type is Scalar;
isNumeric
/** * @param type - The type to check. */$(program).scalar.isNumeric(type: Entity): type is Scalar;
isOffsetDateTime
/** * Check if `type` is exactly the standard offsetDateTime type. * * @param type - The type to check. */$(program).scalar.isOffsetDateTime(type: Entity): type is Scalar;
isPlainDate
/** * Check if `type` is exactly the standard plainDate type. * * @param type - The type to check. */$(program).scalar.isPlainDate(type: Entity): type is Scalar;
isPlainTime
/** * Check if `type` is exactly the standard plainTime type. * * @param type - The type to check. */$(program).scalar.isPlainTime(type: Entity): type is Scalar;
isSafeint
/** * Check if `type` is exactly the standard safeint type. * * @param type - The type to check. */$(program).scalar.isSafeint(type: Entity): type is Scalar;
isString
/** * Check if `type` is exactly the standard string type. * * @param type - The type to check. */$(program).scalar.isString(type: Entity): type is Scalar;
isUint16
/** * Check if `type` is exactly the standard uint16 type. * * @param type - The type to check. */$(program).scalar.isUint16(type: Entity): type is Scalar;
isUint32
/** * Check if `type` is exactly the standard uint32 type. * * @param type - The type to check. */$(program).scalar.isUint32(type: Entity): type is Scalar;
isUint64
/** * Check if `type` is exactly the standard uint64 type. * * @param type - The type to check. */$(program).scalar.isUint64(type: Entity): type is Scalar;
isUint8
/** * Check if `type` is exactly the standard uint8 type. * * @param type - The type to check. */$(program).scalar.isUint8(type: Entity): type is Scalar;
isUrl
/** * Check if `type` is exactly the standard url type. * * @param type - The type to check. */$(program).scalar.isUrl(type: Entity): type is Scalar;
isUtcDateTime
/** * Check if `type` is exactly the standard utcDateTime type. * * @param type - The type to check. */$(program).scalar.isUtcDateTime(type: Entity): type is Scalar;
tuple
create
/** * Creates a tuple type. * * @param values - The tuple values, if any. */$(program).tuple.create(values: Type[]): Tuple;
is
/** * Check if a type is a tuple. */$(program).tuple.is(type: Entity): type is Tuple;
type
clone
/** * Clones a type and adds it to the typekit's realm. * * @param type - Type to clone */$(program).type.clone(type: T): T;
finishType
/** * Finishes a type, applying all the decorators. */$(program).type.finishType(type: Type): void;
getDoc
/** * Get the documentation of this type as specified by the `@doc` decorator or the JSDoc comment. * * @param type - The type to get the documentation for. */$(program).type.getDoc(type: Type): string | undefined;
getEncodedName
/** * Get the name of this type in the specified encoding. */$(program).type.getEncodedName(type: Type & { name: string; },encoding: string): string;
getPlausibleName
/** * Get the plausible name of a type. If the type has a name, it will use it otherwise it will try generate a name based on the context. If the type can't get a name, it will return an empty string. If the type is a TemplateInstance, it will prefix the name with the template arguments. * * @param type - The scalar to get the name of.z */$(program).type.getPlausibleName(type: Model | Union | Enum | Scalar): string;
getSummary
/** * Get the summary of this type as specified by the `@summary` decorator. * * @param type - The type to get the summary for. */$(program).type.getSummary(type: Type): string | undefined;
inNamespace
/** * Checks if the given type is in the given namespace (directly or indirectly) by walking up the type's namespace chain. * * @param type - The type to check. * * @param namespace - The namespace to check membership against. * * @returns True if the type is in the namespace, false otherwise. */$(program).type.inNamespace(type: Type, namespace: Namespace): boolean;
is
/** * Checks if `entity` is a Type. * * @param entity - The entity to check. */$(program).type.is(entity: Entity): entity is Type;
isAssignableTo Diagnosable
/** * Check if the source type can be assigned to the target. * * @param source - Source type * * @param target - Target type * * @param diagnosticTarget - Target for the diagnostic */$(program).type .isAssignableTo(source: Type, target: Entity, diagnosticTarget?: Entity | Node): boolean;$(program).type.isAssignableTo .withDiagnostics(source: Type, target: Entity, diagnosticTarget?: Entity | Node): [boolean, readonly Diagnostic[]];
isError
/** * Checks if a type is decorated with `@error` * * @param type - The type to check. */$(program).type.isError(type: Type): type is Model;
isNever
/** * Checks if the given type is a never type. */$(program).type.isNever(type: Type): boolean;
isUserDefined
/** * Checks if the given type is a user defined type. Non-user defined types are defined in the compiler or other libraries imported by the spec. * * @param type - The type to check. * * @returns True if the type is a user defined type, false otherwise. */$(program).type.isUserDefined(type: Type): boolean;
maxItems
/** * Gets the maximum number of items for an array type. * * @param type - type to get the maximum number of items for */$(program).type.maxItems(type: Type): number | undefined;
maxLength
/** * Gets the maximum length for a string type. * * @param type - type to get the maximum length for */$(program).type.maxLength(type: Type): number | undefined;
maxValue
/** * Gets the maximum value for a numeric or model property type. * * @param type - type to get the maximum value for */$(program).type.maxValue(type: Type): number | undefined;
maxValueExclusive
/** * Gets the maximum value this numeric type should be, exclusive of the given value. * * @param type - */$(program).type.maxValueExclusive(type: Type): number | undefined;
minItems
/** * Gets the minimum number of items for an array type. * * @param type - type to get the minimum number of items for */$(program).type.minItems(type: Type): number | undefined;
minLength
/** * Gets the minimum length for a string type. * * @param type - type to get the minimum length for */$(program).type.minLength(type: Type): number | undefined;
minValue
/** * Gets the minimum value for a numeric or model property type. * * @param type - type to get the minimum value for */$(program).type.minValue(type: Type): number | undefined;
minValueExclusive
/** * Gets the minimum value this numeric type should be, exclusive of the given value. * * @param type - type to get the minimum value for */$(program).type.minValueExclusive(type: Type): number | undefined;
resolve Diagnosable
/** * Resolve a type reference to a TypeSpec type. By default any diagnostics are ignored. * * If a `kind` is provided, it will check if the resolved type matches the expected kind and throw an error if it doesn't. * * Call `type.resolve.withDiagnostics("reference")` to get a tuple containing the resolved type and any diagnostics. */$(program).type .resolve(<K extends Type): ["kind"] | undefined>(reference: string, kind?: KK extends Type["kind"] ? Extract<Type, { kind: K; }> : undefined);$(program).type.resolve .withDiagnostics(<K extends Type): [["kind"] | undefined>(reference: string, kind?: KK extends Type["kind"] ? Extract<Type, { kind: K; }> : undefined), readonly Diagnostic[]];
union
Utilities for working with unions.
create
/** * Create an anonymous union type from an array of types. * * @param children - The types to create a union from. * * Any API documentation will be rendered and preserved in the resulting union. * * No other decorators are copied from the enum to the union. */$(program).union.create(children: Type[]): Union;
createFromEnum
/** * Creates a union type from an enum. * * @remarks * * @param type - The enum to create a union from. * * For member without an explicit value, the member name is used as the value. * * Any API documentation will be rendered and preserved in the resulting union. * * No other decorators are copied from the enum to the union. */$(program).union.createFromEnum(type: Enum): Union;
filter
/** * Creates a union type with filtered variants. * * @param filterFn - Function to filter the union variants */$(program).union.filter(union: Union,filterFn: (variant: UnionVariant) => boolean): Union;
getDiscriminatedUnion Diagnosable
/** * Resolves a discriminated union for the given union. * * @param type - Union to resolve the discriminated union for. */$(program).union .getDiscriminatedUnion(type: Union): DiscriminatedUnion | undefined;$(program).union.getDiscriminatedUnion .withDiagnostics(type: Union): [DiscriminatedUnion | undefined, readonly Diagnostic[]];
is
/** * Check if the given `type` is a union. * * @param type - The type to check. */$(program).union.is(type: Entity): type is Union;
isExpression
/** * Checks if an union is an expression (anonymous) or declared. * * @param type - Uniton to check if it is an expression */$(program).union.isExpression(type: Union): boolean;
isExtensible
/** * Check if a union is extensible. Extensible unions are unions which contain a variant that is a supertype of all the other types. This means that the subtypes of the common supertype are known example values, but others may be present. * * @param type - The union to check. */$(program).union.isExtensible(type: Union): boolean;
isValidEnum
/** * Check if the union is a valid enum. Specifically, this checks if the union has a name (since there are no enum expressions), and whether each of the variant types is a valid enum member value. * * @param type - The union to check. */$(program).union.isValidEnum(type: Union): boolean;
unionVariant
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.
create
/** * Create a union variant. * * @param desc - The descriptor of the union variant. */$(program).unionVariant.create(desc: UnionVariantDescriptor): UnionVariant;
is
/** * Check if the given `type` is a union. * * @param type - The type to check. */$(program).unionVariant.is(type: Entity): type is UnionVariant;
value
create
/** * Create a Value type from a JavaScript value. * * @param value - The JavaScript value to turn into a TypeSpec Value type. */$(program).value.create(value: string | number | boolean): Value;
createBoolean
/** * Create a boolean Value type from a JavaScript boolean value. * * @param value - The boolean value. */$(program).value.createBoolean(value: boolean): BooleanValue;
createNumeric
/** * Create a numeric Value type from a JavaScript number value. * * @param value - The numeric value. */$(program).value.createNumeric(value: number): NumericValue;
createString
/** * Create a string Value type from a JavaScript string value. * * @param value - The string value. */$(program).value.createString(value: string): StringValue;
is
/** * Check if `type` is a Value type. * * @param type - The type to check. */$(program).value.is(type: Entity): type is Value;
isArray
/** * Check if `type` is an array value type * * @param type - The type to check. */$(program).value.isArray(type: Entity): type is ArrayValue;
isAssignableTo Diagnosable
/** * Check if the source type can be assigned to the target. * * @param source - Source type * * @param target - Target type * * @param diagnosticTarget - Target for the diagnostic */$(program).value .isAssignableTo(source: Value, target: Entity, diagnosticTarget?: Entity | Node): boolean;$(program).value.isAssignableTo .withDiagnostics(source: Value, target: Entity, diagnosticTarget?: Entity | Node): [boolean, readonly Diagnostic[]];
isBoolean
/** * Check if `type` is a boolean Value type. * * @param type - The type to check. */$(program).value.isBoolean(type: Entity): type is BooleanValue;
isEnum
/** * Check if `type` is an enum value type * * @param type - The type to check. */$(program).value.isEnum(type: Entity): type is EnumValue;
isNull
/** * Check if `type` is a null value Type. * * @param type - The type to check. */$(program).value.isNull(type: Entity): type is NullValue;
isNumeric
/** * Check if `type` is a numeric Value type. * * @param type - The type to check. */$(program).value.isNumeric(type: Entity): type is NumericValue;
isObject
/** * Check if `type` is an object value type * * @param type - The type to check. */$(program).value.isObject(type: Entity): type is ObjectValue;
isScalar
/** * Check if `type` is a scalar value type * * @param type - The type to check. */$(program).value.isScalar(type: Entity): type is ScalarValue;
isString
/** * Check if `type` is a string Value type. * * @param type - The type to check. */$(program).value.isString(type: Entity): type is StringValue;
resolve Diagnosable
/** * Resolve a value reference to a TypeSpec value. By default any diagnostics are ignored. * * If a `kind` is provided, it will check if the resolved value matches the expected kind and throw an error if it doesn't. * * Call `value.resolve.withDiagnostics("reference")` to get a tuple containing the resolved value and any diagnostics. */$(program).value .resolve(<K extends Value): ["valueKind"] | undefined>(reference: string, kind?: KK extends Value["valueKind"] ? Extract<Value, { valueKind: K; }> : undefined);$(program).value.resolve .withDiagnostics(<K extends Value): [["valueKind"] | undefined>(reference: string, kind?: KK extends Value["valueKind"] ? Extract<Value, { valueKind: K; }> : undefined), readonly Diagnostic[]];