Skip to content

Commit 0f47c04

Browse files
author
Dmitry Dutikov
committed
Typescript declaration added
1 parent fb4fe55 commit 0f47c04

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Note: JSON22 cannot be used as drop in JSON object replacement due to `parse` an
5252
arguments incompatibility. But you may not be worried in case you are using first arguments only.
5353
```typescript
5454
class JSON22 {
55-
static parse(text: string, options?: Json22ParseOptions): any;
55+
static parse<T>(text: string, options?: Json22ParseOptions): T;
5656
static stringify(value: any, options?: Json22StringifyOptions): string;
5757
}
5858

index.d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export declare class JSON22 {
2+
static parse<T>(text: string, options?: Json22ParseOptions): T;
3+
static stringify(value: any, options?: Json22StringifyOptions): string;
4+
}
5+
6+
export interface Json22ParseOptions {
7+
context?: Record<string, { new (...args: any) }>; // default { 'Date': Date }
8+
// To be extended
9+
}
10+
11+
export interface Json22StringifyOptions {
12+
// To be extended
13+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json22",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "JSON superset with an ability to deal with classes and extended support for number values",
55
"author": "Dmitry Dutikov",
66
"license": "MIT",

0 commit comments

Comments
 (0)