1.1.1 • Published 1 year ago

@gabroberge/ts-json-as-const v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ts-json-as-const

License: MIT

Server checks

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

šŸ‘¤ Bethany Hitch (Original Author)

1.1.1

1 year ago

1.1.0

1 year ago

1.0.8

1 year ago