Skip to content

Commit

Permalink
Typescript declaration added
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Dutikov committed Feb 6, 2022
1 parent fb4fe55 commit 0f47c04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(text: string, options?: Json22ParseOptions): T;
static stringify(value: any, options?: Json22StringifyOptions): string;
}

Expand Down
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export declare class JSON22 {
static parse<T>(text: string, options?: Json22ParseOptions): T;
static stringify(value: any, options?: Json22StringifyOptions): string;
}

export interface Json22ParseOptions {
context?: Record<string, { new (...args: any) }>; // default { 'Date': Date }
// To be extended
}

export interface Json22StringifyOptions {
// To be extended
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0f47c04

Please sign in to comment.