Skip to content

Commit 9178705

Browse files
authored
ref(ts): Convert formatters.jsx to TypeScript (#14302)
Add the User and CommitAuthor type
1 parent 542c70e commit 9178705

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/sentry/static/sentry/app/types/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ export type EventsStats = {
5252
data: EventsStatsData;
5353
totals?: {count: number};
5454
};
55+
56+
export type User = {
57+
id: string;
58+
name: string;
59+
username: string;
60+
email: string;
61+
};
62+
63+
export type CommitAuthor = {
64+
email?: string;
65+
name?: string;
66+
};
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {get} from 'lodash';
22

33
import {t} from 'app/locale';
4+
import {CommitAuthor, User} from 'app/types';
45

5-
export function userDisplayName(user) {
6+
export function userDisplayName(user: User | CommitAuthor): string {
67
let displayName = String(get(user, 'name', t('Unknown author'))).trim();
78

89
if (displayName.length <= 0) {
@@ -12,7 +13,7 @@ export function userDisplayName(user) {
1213
const email = String(get(user, 'email', '')).trim();
1314

1415
if (email.length > 0 && email !== displayName) {
15-
displayName += ' (' + user.email + ')';
16+
displayName += ' (' + email + ')';
1617
}
1718
return displayName;
1819
}

0 commit comments

Comments
 (0)