Skip to content

Commit 91db6e6

Browse files
committed
Added JSON types.
1 parent c837e98 commit 91db6e6

5 files changed

Lines changed: 42 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
### 1.3.3
4+
5+
#### Added
6+
7+
- `JSON` types
8+
39
### 1.3.2
410

511
#### Added

docs/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,26 @@ class ApiClient extends mixinApiPostUser(mixinApiGetUser(ExchangeClient)) {}
7171
### Key of class
7272

7373
```typescript
74-
import { keyOfClass } from '@corefunc/type/class/key-of-class';
74+
import { keyOfClass } from "@corefunc/type/class/key-of-class";
7575
class User {
76-
public static readonly name: string = keyOfClass<User>('name');
76+
public static readonly name: string = keyOfClass<User>("name");
7777
public readonly name: string;
7878
}
7979
```
8080

81+
## JSON
82+
83+
### JSON types
84+
85+
```typescript
86+
import type {
87+
JsonPrimitiveType,
88+
JsonArrayType,
89+
JsonObjectType,
90+
JsonType,
91+
} from "@corefunc/type/json";
92+
```
93+
8194
## Number
8295

8396
### Float

json/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export declare type JsonPrimitiveType = boolean | null | number | string;
2+
export interface JsonArrayType extends Array<JsonType> {
3+
[key: number]: JsonType;
4+
}
5+
export interface JsonObjectType extends Record<string, JsonType> {
6+
[key: string]: JsonType;
7+
}
8+
export declare type JsonType = JsonPrimitiveType | JsonArrayType | JsonObjectType;

json/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type JsonPrimitiveType = boolean | null | number | string;
2+
3+
export interface JsonArrayType extends Array<JsonType> {
4+
[key: number]: JsonType;
5+
}
6+
7+
export interface JsonObjectType extends Record<string, JsonType> {
8+
[key: string]: JsonType;
9+
}
10+
11+
export type JsonType = JsonPrimitiveType | JsonArrayType | JsonObjectType;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"class/key-of-class.d.ts",
3131
"class/key-of-class.js",
3232
"class/key-of-class.ts",
33+
"json/index.d.ts",
3334
"number/float-range.type.js",
3435
"number/float-range.type.d.ts",
3536
"number/index.js",
@@ -82,5 +83,5 @@
8283
"test": "echo \"Error: no test specified\" && exit 1"
8384
},
8485
"types": "./index.d.ts",
85-
"version": "1.3.2"
86+
"version": "1.3.3"
8687
}

0 commit comments

Comments
 (0)