Releases: GLINCKER/json-to-typescript
v1.0.2 - First Release
Release Notes: @typeweaver/json2ts v1.0.2
We’re thrilled to announce the release of @typeweaver/json2ts v1.0.2, bringing new features, enhanced performance, and bug fixes. This update focuses on improving usability, adding more flexibility to the TypeScript interface generation process, and ensuring a seamless developer experience.
🚀 What's New in v1.0.2
1. Improved Type Handling for Empty Arrays
In this version, the tool now accurately handles empty arrays by assigning them the any[]
type. This enhancement ensures that developers can work with empty arrays confidently without manual type adjustments.
- Accurate Typing: Empty arrays are now explicitly typed as
any[]
, reducing ambiguity in the generated interfaces.
2. Circular Reference Detection
Robust circular reference detection has been added to prevent runtime errors and ensure that all generated interfaces are valid and logical.
- Error Handling: If a circular reference is detected, the tool will throw an error with a detailed message, ensuring that developers can address the issue quickly.
3. Enhanced TypeScript Definitions
The package now includes improved TypeScript definitions, making it easier for TypeScript developers to integrate the library into their projects seamlessly.
- Better Typing: Updated type definitions ensure compatibility with various project setups.
4. Performance Optimizations
The JSON-to-TypeScript conversion process has been optimized for faster execution, especially when dealing with large and deeply nested JSON objects.
🐛 Bug Fixes
- Resolved empty object handling: Empty objects are now correctly represented with their own interface instead of defaulting to
any
. - Fixed depth calculation for nested arrays: Nested arrays now correctly calculate their depth, ensuring accurate
T[][]
types. - Correct TypeScript declarations: The
package.json
file has been updated to ensure correct mapping to declaration files.
✨ Example
Input JSON:
{
"name": "John",
"age": 30,
"address": {
"city": "New York",
"zip": "10001"
}
}
Generated TypeScript Interface:
interface Root {
name: string;
age: number;
address: {
city: string;
zip: string;
};
}
📦 Installation
Install the package using your preferred package manager:
Using NPM:
npm install -g @typeweaver/json2ts
Using Yarn:
yarn global add @typeweaver/json2ts
Using PNPM:
pnpm add -g @typeweaver/json2ts
🛠️ Usage
Programmatic API:
import { convertJsonToTs } from '@typeweaver/json2ts';
const json = { name: "John", age: 30 };
const tsInterface = convertJsonToTs(json);
console.log(tsInterface);
// Output:
// interface Root {
// name: string;
// age: number;
// }