()
| 396 | } |
| 397 | |
| 398 | function createTypes() { |
| 399 | const enPath = path.resolve(dir, "en-us.json"); |
| 400 | const enData = JSON.parse(fs.readFileSync(enPath, "utf8")); |
| 401 | const keys = Object.keys(enData); |
| 402 | |
| 403 | const typeDef = `// Auto-generated by 'pnpm lang createTypes' |
| 404 | // Do not edit manually |
| 405 | |
| 406 | declare type LangStrings = { |
| 407 | ${keys.map((k) => ` ${JSON.stringify(k)}: string;`).join("\n")} |
| 408 | }; |
| 409 | |
| 410 | declare var strings: LangStrings; |
| 411 | `; |
| 412 | |
| 413 | const typePath = path.resolve(dir, "index.d.ts"); |
| 414 | fs.writeFileSync(typePath, typeDef, "utf8"); |
| 415 | console.log(`Generated types for ${keys.length} keys in src/lang/index.d.ts`); |
| 416 | } |
no test coverage detected