typed-t
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

typed-t

generate typescript declarations from json translation files

Currently supports:

install

npm i typed-t -D

use

// generate-decl.ts
import { generateTypes, Options, DialectOptions } from 'typed-t';

const dialectOpts: DialectOptions = {
  name: 'polyglot',

  /* Custom prefix for interpolations */
  // prefix: '{'

  /* Custom suffix for interpolations */
  // suffix: '}'
};
const options: Options = {
  /* Single json file or directory containing t9n files */
  entry: __dirname + '/locales',

  /* Specify target dialect and options */
  dialect: dialectOpts,

  /* Custom directory to put declaration files in (Default: same as input dir) */
  // outDir: __dirname + '/locale-declarations

  /* Custom filter to include only specific files */
  // include: (name: string, content: Buffer) => true

  /* Consider files in sub-folders? (Default: true) */
  // recursive: false

  /* Custom file system compatible with node:fs/promises */
  // fs: myCustomFileSystem

  /* Custom node:path implementation */
  // path: myCustomPath
};

generateTypes(options)
  .then(() => {
    console.log('DONE');
  })
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });

then run

node -r esbuild-register generate-decl.ts

How you incorporate the types in your app is highly dependant on your setup so this tool can not help you with that, sorry.

Package Sidebar

Install

npm i typed-t

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

54.4 kB

Total Files

10

Last publish

Collaborators

  • xiphe