# gt: General Translation CLI tool: TypeScript and JavaScript URL: https://generaltranslation.com/en-US/docs/cli/reference/formats/ts-js-files.mdx --- title: TypeScript and JavaScript description: Translate TypeScript and JavaScript files with the General Translation CLI. API reference for the TypeScript and JavaScript file formats. --- The CLI translates TypeScript (`ts`) and JavaScript (`js`) files. All syntax and formatting in the source files is preserved in the translated files. ## Overview [#overview] | Topic | Description | | --- | --- | | [Configuration](#config) | Select source files and translated output paths. | | [Static data exports](#data-exports) | Reuse unchanged strings in eligible exports. | ## Configuration [#config] Add a `ts` or `js` entry under `files` with an `include` array of glob patterns. Use the `[locale]` placeholder so the CLI can find source files and save translations to the right path. ```json title="gt.config.json" { "defaultLocale": "en", "locales": ["fr", "es"], "files": { "ts": { "include": ["scripts/[locale]/**/*.ts"] } } } ``` This translates every TypeScript file under `scripts/en` and saves the results to `scripts/fr` and `scripts/es`. Use the `js` key instead for JavaScript files. See the [configuration reference](/docs/cli/reference/config#files) for all file keys. ## Update static data exports [#data-exports] When an updated TypeScript or JavaScript file contains static data exports, General Translation reuses matching strings from earlier translations and translates only new or changed strings. Reuse applies when every exported variable in the chunk contains only static string, number, bigint, boolean, or `null` literals, arrays, and plain objects. TypeScript assertion wrappers are supported. Exports with spreads, identifiers, function calls, template literals, JSX, or computed object keys use the standard translation path. Running [`gt translate --force`](/docs/cli/reference/commands/translate) or applying Glossary translations also skips incremental reuse.