Skip to content

Commit e327235

Browse files
authored
feat: update types to allow type narrowing (#535)
1 parent 8499afa commit e327235

32 files changed

+265
-121
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
22
dist
3-
.yarn/*
4-
!.yarn/releases
3+
build

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "resend",
3-
"version": "4.6.0",
3+
"version": "4.7.0-canary.0",
44
"description": "Node.js library for the Resend API",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

src/api-keys/interfaces/create-api-key-options.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ export interface CreateApiKeyResponseSuccess {
1414
id: string;
1515
}
1616

17-
export interface CreateApiKeyResponse {
18-
data: CreateApiKeyResponseSuccess | null;
19-
error: ErrorResponse | null;
20-
}
17+
export type CreateApiKeyResponse =
18+
| {
19+
data: CreateApiKeyResponseSuccess;
20+
error: null;
21+
}
22+
| {
23+
data: null;
24+
error: ErrorResponse;
25+
};

src/api-keys/interfaces/list-api-keys.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ export type ListApiKeysResponseSuccess = Pick<
66
'name' | 'id' | 'created_at'
77
>[];
88

9-
export interface ListApiKeysResponse {
10-
data: ListApiKeysResponseSuccess | null;
11-
error: ErrorResponse | null;
12-
}
9+
export type ListApiKeysResponse =
10+
| {
11+
data: ListApiKeysResponseSuccess;
12+
error: null;
13+
}
14+
| {
15+
data: null;
16+
error: ErrorResponse;
17+
};

src/api-keys/interfaces/remove-api-keys.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import type { ErrorResponse } from '../../interfaces';
33
// biome-ignore lint/complexity/noBannedTypes: <explanation>
44
export type RemoveApiKeyResponseSuccess = {};
55

6-
export interface RemoveApiKeyResponse {
7-
data: RemoveApiKeyResponseSuccess | null;
8-
error: ErrorResponse | null;
9-
}
6+
export type RemoveApiKeyResponse =
7+
| {
8+
data: RemoveApiKeyResponseSuccess;
9+
error: null;
10+
}
11+
| {
12+
data: null;
13+
error: ErrorResponse;
14+
};

src/audiences/interfaces/create-audience-options.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ export interface CreateAudienceResponseSuccess
1313
object: 'audience';
1414
}
1515

16-
export interface CreateAudienceResponse {
17-
data: CreateAudienceResponseSuccess | null;
18-
error: ErrorResponse | null;
19-
}
16+
export type CreateAudienceResponse =
17+
| {
18+
data: CreateAudienceResponseSuccess;
19+
error: null;
20+
}
21+
| {
22+
data: null;
23+
error: ErrorResponse;
24+
};

src/audiences/interfaces/get-audience.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ export interface GetAudienceResponseSuccess
66
object: 'audience';
77
}
88

9-
export interface GetAudienceResponse {
10-
data: GetAudienceResponseSuccess | null;
11-
error: ErrorResponse | null;
12-
}
9+
export type GetAudienceResponse =
10+
| {
11+
data: GetAudienceResponseSuccess;
12+
error: null;
13+
}
14+
| {
15+
data: null;
16+
error: ErrorResponse;
17+
};

src/audiences/interfaces/list-audiences.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ export type ListAudiencesResponseSuccess = {
66
data: Audience[];
77
};
88

9-
export interface ListAudiencesResponse {
10-
data: ListAudiencesResponseSuccess | null;
11-
error: ErrorResponse | null;
12-
}
9+
export type ListAudiencesResponse =
10+
| {
11+
data: ListAudiencesResponseSuccess;
12+
error: null;
13+
}
14+
| {
15+
data: null;
16+
error: ErrorResponse;
17+
};

src/audiences/interfaces/remove-audience.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ export interface RemoveAudiencesResponseSuccess extends Pick<Audience, 'id'> {
66
deleted: boolean;
77
}
88

9-
export interface RemoveAudiencesResponse {
10-
data: RemoveAudiencesResponseSuccess | null;
11-
error: ErrorResponse | null;
12-
}
9+
export type RemoveAudiencesResponse =
10+
| {
11+
data: RemoveAudiencesResponseSuccess;
12+
error: null;
13+
}
14+
| {
15+
data: null;
16+
error: ErrorResponse;
17+
};

src/batch/interfaces/create-batch-options.interface.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ export interface CreateBatchSuccessResponse {
1616
}[];
1717
}
1818

19-
export interface CreateBatchResponse {
20-
data: CreateBatchSuccessResponse | null;
21-
error: ErrorResponse | null;
22-
}
19+
export type CreateBatchResponse =
20+
| {
21+
data: CreateBatchSuccessResponse;
22+
error: null;
23+
}
24+
| {
25+
data: null;
26+
error: ErrorResponse;
27+
};

0 commit comments

Comments
 (0)