Skip to content

Commit d36a9ac

Browse files
committed
fix: replaced NoData type with ObjectEmpty
[ci skip]
1 parent 1ca6ea5 commit d36a9ac

3 files changed

Lines changed: 42 additions & 35 deletions

File tree

src/agent/types.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import type { JSONValue } from '../types';
2-
3-
// eslint-disable-next-line
4-
type NoData = {};
1+
import type { JSONValue, ObjectEmpty } from '../types';
52

63
// Prevent overwriting the metadata type with `Omit<>`
7-
type AgentRPCRequestParams<T extends Record<string, JSONValue> = NoData> = {
8-
metadata?: {
9-
[Key: string]: JSONValue;
10-
} & Partial<{
11-
authorization: string;
12-
timeout: number;
13-
}>;
14-
} & Omit<T, 'metadata'>;
4+
type AgentRPCRequestParams<T extends Record<string, JSONValue> = ObjectEmpty> =
5+
{
6+
metadata?: {
7+
[Key: string]: JSONValue;
8+
} & Partial<{
9+
authorization: string;
10+
timeout: number;
11+
}>;
12+
} & Omit<T, 'metadata'>;
1513

1614
// Prevent overwriting the metadata type with `Omit<>`
17-
type AgentRPCResponseResult<T extends Record<string, JSONValue> = NoData> = {
18-
metadata?: {
19-
[Key: string]: JSONValue;
20-
} & Partial<{
21-
authorization: string;
22-
timeout: number;
23-
}>;
24-
} & Omit<T, 'metadata'>;
15+
type AgentRPCResponseResult<T extends Record<string, JSONValue> = ObjectEmpty> =
16+
{
17+
metadata?: {
18+
[Key: string]: JSONValue;
19+
} & Partial<{
20+
authorization: string;
21+
timeout: number;
22+
}>;
23+
} & Omit<T, 'metadata'>;
2524

26-
export type { AgentRPCRequestParams, AgentRPCResponseResult, NoData };
25+
export type { AgentRPCRequestParams, AgentRPCResponseResult };

src/client/types.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import type { JSONValue } from '../types';
2-
3-
// eslint-disable-next-line
4-
type NoData = {};
1+
import type { JSONValue, ObjectEmpty } from '../types';
52

63
// Prevent overwriting the metadata type with `Omit<>`
7-
type ClientRPCRequestParams<T extends Record<string, JSONValue> = NoData> = {
8-
metadata?: {
9-
[Key: string]: JSONValue;
10-
} & Partial<{
11-
authorization: string;
12-
timeout: number;
13-
}>;
14-
} & Omit<T, 'metadata'>;
4+
type ClientRPCRequestParams<T extends Record<string, JSONValue> = ObjectEmpty> =
5+
{
6+
metadata?: {
7+
[Key: string]: JSONValue;
8+
} & Partial<{
9+
authorization: string;
10+
timeout: number;
11+
}>;
12+
} & Omit<T, 'metadata'>;
1513

1614
// Prevent overwriting the metadata type with `Omit<>`
17-
type ClientRPCResponseResult<T extends Record<string, JSONValue> = NoData> = {
15+
type ClientRPCResponseResult<
16+
T extends Record<string, JSONValue> = ObjectEmpty,
17+
> = {
1818
metadata?: {
1919
[Key: string]: JSONValue;
2020
} & Partial<{
@@ -23,4 +23,4 @@ type ClientRPCResponseResult<T extends Record<string, JSONValue> = NoData> = {
2323
}>;
2424
} & Omit<T, 'metadata'>;
2525

26-
export type { ClientRPCRequestParams, ClientRPCResponseResult, NoData };
26+
export type { ClientRPCRequestParams, ClientRPCResponseResult };

src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ type InverseRecord<
151151
[K in M[keyof M]]: RecordKeyFromValue<M, K>;
152152
};
153153

154+
/**
155+
* Used when an empty object is needed.
156+
* Defined here with a linter override to avoid a false positive.
157+
*/
158+
// eslint-disable-next-line
159+
type ObjectEmpty = {};
160+
154161
export type {
155162
POJO,
156163
JSONValue,
@@ -171,4 +178,5 @@ export type {
171178
NonFunctionProperties,
172179
RecordKeyFromValue,
173180
InverseRecord,
181+
ObjectEmpty,
174182
};

0 commit comments

Comments
 (0)