function getTypeScriptType()

in src/scripts/build/nimbusTypes.js [247:275]


function getTypeScriptType(type) {
  if (type === "String") {
    return "string";
  }
  if (type === "Boolean") {
    return "boolean";
  }
  if (type === "Int") {
    return "number";
  }
  if (type === "Text" || type === "Image") {
    return "string";
  }
  if (type.startsWith("Option<")) {
    const t = type.substring("Option<".length, type.length - 1).trim();
    return `null | ${getTypeScriptType(t)}`;
  }
  if (type.startsWith("List<")) {
    const t = type.substring("List<".length, type.length - 1).trim();
    return `Array<${getTypeScriptType(t)}>`;
  }
  if (type.startsWith("Map<")) {
    const kv = type.substring("Map<".length, type.length - 1).trim();
    const [k, v] = kv.split(",").map((part) => part.trim());
    return `Record<${getTypeScriptType(k)}, ${getTypeScriptType(v)}>`;
  }

  return type;
}