a2a-js/scripts/generateTypes.js
swapydapy bcc1f7e0e1
feat: use string union instead of enums (#24)
* feat: use string union instead of enum

* chore: remove IInterface naming

* fix readme

* fix quote consistency
2025-06-12 17:20:26 -07:00

15 lines
479 B
JavaScript

import { compile, compileFromFile } from 'json-schema-to-typescript'
import fs from 'fs';
import path from 'path';
const typeSchemaContents = fs.readFileSync(path.join(process.cwd(), 'spec.json'), 'utf8');
const typeSchema = JSON.parse(typeSchemaContents.toString());
compile(typeSchema, 'MySchema', {
additionalProperties: false,
enableConstEnums: false,
unreachableDefinitions: true,
unknownAny: true,
})
.then(ts => fs.writeFileSync('src/types.ts', ts))