Skip to content
Get in touch

Other core types

A value that is either true or false, equivalent to boolean in JSON Schema.

A JSON example of this model.

true

An ordered list of values, equivalent to array in JSON Schema.

A JSON example of this model.

[1, 2, 3]

In TypeSpec, you can specify the type of the values in the array with templating:

/** An array of integers */
alias IntegerArray = Array<integer>

This is equivalent to the following JSON Schema:

$id: IntegerArray.yaml
type: array
items:
type: integer

A collection of key-value pairs, equivalent to object in JSON Schema.

A JSON example of this model.

{
"foo": 1,
"bar": 2
}

In TypeSpec, you can specify the type of the values in the record with templating:

/** A record with a string key and an integer value */
alias StringIntRecord = Record<integer>

This is equivalent to the following JSON Schema:

$id: StringIntRecord.yaml
type: object
additionalProperties:
type: integer

If you want to define specific keys in a record, you can do so with a model.

The null type, equivalent to null in JSON Schema.

A JSON example of this model.

null

The unknown type accepts any value. It is equivalent to an empty JSON Schema.

A JSON example of this model.

// String
"foo"
// Integer
123
// Boolean
true