From 0f47c0402f016a386fae79322936ff8d1b22a2f8 Mon Sep 17 00:00:00 2001 From: Dmitry Dutikov Date: Sun, 6 Feb 2022 12:09:46 +0500 Subject: [PATCH] Typescript declaration added --- README.md | 2 +- index.d.ts | 13 +++++++++++++ package.json | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 index.d.ts diff --git a/README.md b/README.md index 5ace2f0..c6c2c5e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Note: JSON22 cannot be used as drop in JSON object replacement due to `parse` an arguments incompatibility. But you may not be worried in case you are using first arguments only. ```typescript class JSON22 { - static parse(text: string, options?: Json22ParseOptions): any; + static parse(text: string, options?: Json22ParseOptions): T; static stringify(value: any, options?: Json22StringifyOptions): string; } diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..5fa2829 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,13 @@ +export declare class JSON22 { + static parse(text: string, options?: Json22ParseOptions): T; + static stringify(value: any, options?: Json22StringifyOptions): string; +} + +export interface Json22ParseOptions { + context?: Record; // default { 'Date': Date } + // To be extended +} + +export interface Json22StringifyOptions { + // To be extended +} diff --git a/package.json b/package.json index bf09fa1..4ffd3d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "json22", - "version": "0.0.5", + "version": "0.0.6", "description": "JSON superset with an ability to deal with classes and extended support for number values", "author": "Dmitry Dutikov", "license": "MIT",