@gabroberge/ts-json-as-const
v1.1.1
Published
A (very) simple CLI tool that reads JSON files and creates .d.ts files with their keys/values explicitly defined
Downloads
16
Maintainers
Readme
ts-json-as-const
Installation
Install with pnpm
pnpm add @gabroberge/ts-json-as-const
Install with yarn
yarn add @gabroberge/ts-json-as-const
Install with npm
npm install --save @gabroberge/ts-json-as-const
Usage
npx ts-json-as-const [path/to/json/file.json ...]
pnpm dlx ts-json-as-const [path/to/json/file.json ...]
Examples
Input example.json
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
Output example.json.d.ts
export type Tsconfig = {
compilerOptions: {
target: 'es2016';
module: 'commonjs';
strict: true;
esModuleInterop: true;
skipLibCheck: true;
forceConsistentCasingInFileNames: true;
};
};
declare const Tsconfig: Tsconfig;
export = Tsconfig;
Input array.json
[
{
"name": "John",
"age": 30,
"cars": [
{
"name": "Ford",
"models": [{ "name": "Fiesta" }, { "name": "Focus" }]
},
{
"name": "BMW",
"models": [{ "name": "320" }, { "name": "X3" }]
},
{
"name": "Fiat",
"models": [{ "name": "500" }, { "name": "Panda" }]
}
]
}
]
Output array.json.d.ts
export type Array = [
{
name: 'John';
age: 30;
cars: [
{ name: 'Ford'; models: [{ name: 'Fiesta' }, { name: 'Focus' }] },
{ name: 'BMW'; models: [{ name: '320' }, { name: 'X3' }] },
{ name: 'Fiat'; models: [{ name: '500' }, { name: 'Panda' }] },
];
},
];
declare const Array: Array;
export = Array;
Authors
👤 Gabriel Roberge
- Github: @gabroberge
👤 Bethany Hitch (Original Author)
- Github: @dfoverdx