@gabroberge/ts-json-as-const
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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)

Package Sidebar

Install

npm i @gabroberge/ts-json-as-const

Weekly Downloads

2

Version

1.1.1

License

MIT

Unpacked Size

12 kB

Total Files

8

Last publish

Collaborators

  • gabroberge