{"id":15485644,"url":"https://github.com/tyderion/webpack-typescript-json-type","last_synced_at":"2026-05-02T14:33:24.123Z","repository":{"id":139700987,"uuid":"118956347","full_name":"Tyderion/webpack-typescript-json-type","owner":"Tyderion","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-26T19:21:42.000Z","size":66,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T06:01:43.210Z","etag":null,"topics":["i18n","typescript","webpack"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tyderion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-25T19:14:42.000Z","updated_at":"2018-02-02T06:42:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"4db23cb9-c578-4b12-a65b-feb7969f72ac","html_url":"https://github.com/Tyderion/webpack-typescript-json-type","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"ecdbc43e0ff4769e419913fbadd3381a84c4d765"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyderion%2Fwebpack-typescript-json-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyderion%2Fwebpack-typescript-json-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyderion%2Fwebpack-typescript-json-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tyderion%2Fwebpack-typescript-json-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tyderion","download_url":"https://codeload.github.com/Tyderion/webpack-typescript-json-type/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246056527,"owners_count":20716758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["i18n","typescript","webpack"],"created_at":"2024-10-02T06:02:13.915Z","updated_at":"2026-05-02T14:33:24.081Z","avatar_url":"https://github.com/Tyderion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-typescript-json-type [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]\n\u003e Generates a type with all json paths for the configured files\n\n## Installation\n\n```sh\n$ npm install --save-dev webpack-typescript-json-type\n```\n\n## Usage\n\n```js\nconst path = require('path');\nconst TranslationKeyTypeGenerator = require('webpack-typescript-json-type');\n```\nthen use it in the plugins section of your config: \n```js\n{\n  plugins: [\n    new TranslationKeyTypeGenerator({ \n      files: [\n        { path: path.resolve(__dirname, './path/to/your/json.json'), class: 'SomeTypeName' },\n        { path: path.resolve(__dirname, './path/to/your/different.json.json'), class: 'ADifferentTypeName' },\n      ], \n      output: path.resolve(__dirname, 'typings_custom'),\n      typefile: 'optional.d.ts' // Defaults to jsontypes.d.ts\n    })\n}\n```\n\nThis will produce to ambient types `SomeTypeName` and `ADifferentTypeName` in the specified file.\nThen you just need to include the type definition file with a reference path and you're good to go `/// \u003creference path=\"path/to/jsontypes.d.ts\"/\u003e` or include it differently.\n\n## Example\nConsider the following file structure (maybe used as a translation file in a webproject).\n```json\n{\n   \"MAIN\": {\n      \"TITLE\": \"Main\",\n      \"WELCOME\": \"Welcome Message\"\n    },\n    \"ABOUT\": {\n      \"TITLE\": \"About\"\n    }\n}\n```\n\nIn most i18n implementations these translations can be used in the form `MAIN.TITLE` or `ABOUT.TITLE`. \nUsing `webpack-typescript-json-type` with the above file content (giving it the name `TranslationKey`) will produce the following type: \n```typescript\ndeclare type TranslationKey = 'MAIN.TITLE' | 'MAIN.WELCOME' | 'ABOUT.TITLE';\n```\n\nThis type then allows your IDE to autocomplete translation keys if typed correctly.\n\n## License\n\nMIT © [Gabriel Nadler](https://github.com/Tyderion)\n\n\n[npm-image]: https://badge.fury.io/js/webpack-typescript-json-type.svg\n[npm-url]: https://npmjs.org/package/webpack-typescript-json-type\n[travis-image]: https://travis-ci.org/Tyderion/webpack-typescript-json-type.svg?branch=master\n[travis-url]: https://travis-ci.org/Tyderion/webpack-typescript-json-type\n[daviddm-image]: https://david-dm.org/Tyderion/webpack-typescript-json-type.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/Tyderion/webpack-typescript-json-type\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyderion%2Fwebpack-typescript-json-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyderion%2Fwebpack-typescript-json-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyderion%2Fwebpack-typescript-json-type/lists"}