Methods
cloneType()
cloneType<T>(type, additionalProps?): T;
Type Parameters
| Type Parameter |
|---|
T extends Type |
Parameters
| Parameter | Type |
|---|
type | T |
additionalProps? | { [P in string | number | symbol]?: T[P] } |
Returns
T
createAndFinishType()
createAndFinishType<T>(typeDef): T & TypePrototype;
Type Parameters
Parameters
Returns
T & TypePrototype
createLiteralType()
Call Signature
createLiteralType(value, node?): StringLiteral;
Parameters
| Parameter | Type |
|---|
value | string |
node? | StringLiteralNode |
Returns
StringLiteral
Call Signature
createLiteralType(value, node?): NumericLiteral;
Parameters
| Parameter | Type |
|---|
value | number |
node? | NumericLiteralNode |
Returns
NumericLiteral
Call Signature
createLiteralType(value, node?): BooleanLiteral;
Parameters
| Parameter | Type |
|---|
value | boolean |
node? | BooleanLiteralNode |
Returns
BooleanLiteral
Call Signature
createLiteralType(value, node?):
Parameters
| Parameter | Type |
|---|
value | string | number | boolean |
node? | StringLiteralNode | NumericLiteralNode | BooleanLiteralNode |
Returns
| BooleanLiteral
| NumericLiteral
| StringLiteral
Call Signature
createLiteralType(value, node?):
Parameters
| Parameter | Type |
|---|
value | string | number | boolean |
node? | StringLiteralNode | NumericLiteralNode | BooleanLiteralNode |
Returns
| BooleanLiteral
| NumericLiteral
| StringLiteral
createType()
createType<T>(typeDef): T & TypePrototype & object;
Type Parameters
Parameters
Returns
T & TypePrototype & object
finishType()
finishType<T>(typeDef): T;
Type Parameters
| Type Parameter |
|---|
T extends Type |
Parameters
Returns
T
getStdType()
getStdType<T>(name): StdTypes[T];
Std type
Type Parameters
Parameters
| Parameter | Type | Description |
|---|
name | T | Name |
Returns
StdTypes[T]
getTypeForNode()
getTypeForNode(node): Type;
Using this API involves working with the TypeSpec Ast and may change at any time.
See https://typespec.io/docs/handbook/breaking-change-policy/
Parameters
Returns
Type
getValueExactType()
getValueExactType(value): undefined | Type;
Return the exact type of a value.
const a: string = "hello";
calling getValueExactType on the value of a would give the string literal “hello”.
Parameters
| Parameter | Type | Description |
|---|
value | Value | |
Returns
undefined | Type
isStdType()
Call Signature
isStdType(type, stdType?): type is Scalar & { name: IntrinsicScalarName };
Check if the given type is one of the built-in standard TypeSpec Types.
Parameters
Returns
type is Scalar & { name: IntrinsicScalarName }
Call Signature
isStdType(type, stdType?): type is Type & { name: "Array" | IntrinsicScalarName | "Record" };
Parameters
Returns
type is Type & { name: “Array” | IntrinsicScalarName | “Record” }