@typespec/compiler
Version:
TypeSpec Compiler Preview
29 lines • 883 B
JavaScript
import { isArrayModelType } from "../../core/type-utils.js";
import { defineKit } from "../define-kit.js";
defineKit({
array: {
is(type) {
return (type.entityKind === "Type" &&
type.kind === "Model" &&
isArrayModelType(this.program, type) &&
type.properties.size === 0);
},
getElementType(type) {
if (!this.array.is(type)) {
throw new Error("Type is not an array.");
}
return type.indexer.value;
},
create(elementType) {
return this.model.create({
name: "Array",
properties: {},
indexer: {
key: this.builtin.integer,
value: elementType,
},
});
},
},
});
//# sourceMappingURL=array.js.map