microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
61ba17d2d29dedf4553b21a055aa6b442a304688

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

packages/compiler/lib/lib.tsp

198lines · modecode

1namespace TypeSpec;
2
3/**
4 * Represent a byte array
5 */
6scalar bytes;
7
8/**
9 * A numeric type
10 */
11scalar numeric;
12
13/**
14 * A whole number
15 */
16scalar integer extends numeric;
17
18/**
19 * A number with decimal value
20 */
21scalar float extends numeric;
22
23/**
24 * A 64-bit integer. (`-9,223,372,036,854,775,808` to `9,223,372,036,854,775,807`)
25 */
26scalar int64 extends integer;
27
28/**
29 * A 32-bit integer. (`-2,147,483,648` to `2,147,483,647`)
30 */
31scalar int32 extends int64;
32
33/**
34 * A 16-bit integer. (`-32,768` to `32,767`)
35 */
36scalar int16 extends int32;
37
38/**
39 * A 8-bit integer. (`-128` to `127`)
40 */
41scalar int8 extends int16;
42
43/**
44 * A 64-bit unsigned integer (`0` to `18,446,744,073,709,551,615`)
45 */
46scalar uint64 extends integer;
47
48/**
49 * A 32-bit unsigned integer (`0` to `4,294,967,295`)
50 */
51scalar uint32 extends uint64;
52
53/**
54 * A 16-bit unsigned integer (`0` to `65,535`)
55 */
56scalar uint16 extends uint32;
57
58/**
59 * A 8-bit unsigned integer (`0` to `255`)
60 */
61scalar uint8 extends uint16;
62
63/**
64 * An integer that can be serialized to JSON (`−9007199254740991 (−(2^53 − 1))` to `9007199254740991 (2^53 − 1)` )
65 */
66scalar safeint extends int64;
67
68/**
69 * A 32 bit floating point number. (`±1.5 x 10^−45` to `±3.4 x 10^38`)
70 */
71scalar float64 extends float;
72
73/**
74 * A 32 bit floating point number. (`±5.0 × 10^−324` to `±1.7 × 10^308`)
75 */
76scalar float32 extends float64;
77
78/**
79 * A decimal number with any length and precision.
80 */
81scalar decimal extends numeric;
82
83/**
84 * A 128-bit decimal number.
85 */
86scalar decimal128 extends decimal;
87
88/**
89 * A sequence of textual characters.
90 */
91scalar string;
92
93/**
94 * A date on a calendar without a time zone, e.g. "April 10th"
95 */
96scalar plainDate;
97
98/**
99 * A time on a clock without a time zone, e.g. "3:00 am"
100 */
101scalar plainTime;
102
103/**
104 * An instant in coordinated universal time (UTC)"
105 */
106scalar utcDateTime;
107
108/**
109 * A date and time in a particular time zone, e.g. "April 10th at 3:00am in PST"
110 */
111scalar offsetDateTime;
112
113/**
114 * A duration/time period. e.g 5s, 10h
115 */
116scalar duration;
117
118/**
119 * Boolean with `true` and `false` values.
120 */
121scalar boolean;
122
123/**
124 * Represent a model
125 */
126// Deprecated June 2023 sprint
127#deprecated "object is deprecated. Please use {} for an empty model, `Record<unknown>` for a record with unknown property types, `unknown[]` for an array."
128model object {}
129
130/**
131 * @dev Array model type, equivalent to `T[]`
132 * @template T The type of the array elements
133 */
134@indexer(integer, T)
135model Array<T> {}
136
137/**
138 * @dev Model with string properties where all the properties have type `T`
139 * @template T The type of the properties
140 */
141@indexer(string, T)
142model Record<T> {}
143
144/**
145 * Represent a URL string as described by https://url.spec.whatwg.org/
146 */
147scalar url extends string;
148
149/**
150 * Represents a collection of optional properties.
151 * @template T An object whose spread properties are all optional.
152 */
153@doc("The template for adding optional properties.")
154@withOptionalProperties
155model OptionalProperties<T> {
156 ...T;
157}
158
159/**
160 * Represents a collection of updateable properties.
161 * @template T An object whose spread properties are all updateable.
162 */
163@doc("The template for adding updateable properties.")
164@withUpdateableProperties
165model UpdateableProperties<T> {
166 ...T;
167}
168
169/**
170 * Represents a collection of omitted properties.
171 * @template T An object whose properties are spread.
172 * @template TKeys The property keys to omit.
173 */
174@doc("The template for omitting properties.")
175@withoutOmittedProperties(TKeys)
176model OmitProperties<T, TKeys extends string> {
177 ...T;
178}
179
180/**
181 * Represents a collection of properties with default values omitted.
182 * @template T An object whose spread property defaults are all omitted.
183 */
184@withoutDefaultValues
185model OmitDefaults<T> {
186 ...T;
187}
188
189/**
190 * Applies a visibility setting to a collection of properties.
191 * @template T An object whose properties are spread.
192 * @template Visibility The visibility to apply to all properties.
193 */
194@doc("The template for setting the default visibility of key properties.")
195@withDefaultKeyVisibility(Visibility)
196model DefaultKeyVisibility<T, Visibility extends valueof string> {
197 ...T;
198}
199