Browse Source

ref(types): extend interface (#37517)

Jonas 2 years ago
parent
commit
761200e368

+ 10 - 13
static/app/types/alerts.tsx

@@ -24,7 +24,7 @@ type IssueAlertRuleFormField =
  * These templates that tell the UI how to render the action or condition
  * These templates that tell the UI how to render the action or condition
  * and what fields it needs
  * and what fields it needs
  */
  */
-export type IssueAlertRuleActionTemplate = {
+export interface IssueAlertRuleActionTemplate {
   enabled: boolean;
   enabled: boolean;
   id: string;
   id: string;
   label: string;
   label: string;
@@ -39,21 +39,18 @@ export type IssueAlertRuleActionTemplate = {
   link?: string;
   link?: string;
   sentryAppInstallationUuid?: string;
   sentryAppInstallationUuid?: string;
   ticketType?: string;
   ticketType?: string;
-};
+}
 export type IssueAlertRuleConditionTemplate = IssueAlertRuleActionTemplate;
 export type IssueAlertRuleConditionTemplate = IssueAlertRuleActionTemplate;
 
 
 /**
 /**
  * These are the action or condition data that the user is editing or has saved.
  * These are the action or condition data that the user is editing or has saved.
  */
  */
-export type IssueAlertRuleAction = Omit<
-  IssueAlertRuleActionTemplate,
-  'formFields' | 'enabled'
-> & {
-  dynamic_form_fields?: IssueConfigField[];
-} & {
+export interface IssueAlertRuleAction
+  extends Omit<IssueAlertRuleActionTemplate, 'formFields' | 'enabled'> {
   // These are the same values as the keys in `formFields` for a template
   // These are the same values as the keys in `formFields` for a template
   [key: string]: any;
   [key: string]: any;
-};
+  dynamic_form_fields?: IssueConfigField[];
+}
 
 
 export type IssueAlertRuleCondition = Omit<
 export type IssueAlertRuleCondition = Omit<
   IssueAlertRuleConditionTemplate,
   IssueAlertRuleConditionTemplate,
@@ -65,7 +62,7 @@ export type IssueAlertRuleCondition = Omit<
   [key: string]: number | string;
   [key: string]: number | string;
 };
 };
 
 
-export type UnsavedIssueAlertRule = {
+export interface UnsavedIssueAlertRule {
   /** When an issue matches [actionMatch] of the following */
   /** When an issue matches [actionMatch] of the following */
   actionMatch: 'all' | 'any' | 'none';
   actionMatch: 'all' | 'any' | 'none';
   actions: IssueAlertRuleAction[];
   actions: IssueAlertRuleAction[];
@@ -77,17 +74,17 @@ export type UnsavedIssueAlertRule = {
   name: string;
   name: string;
   environment?: null | string;
   environment?: null | string;
   owner?: string | null;
   owner?: string | null;
-};
+}
 
 
 // Issue-based alert rule
 // Issue-based alert rule
-export type IssueAlertRule = UnsavedIssueAlertRule & {
+export interface IssueAlertRule extends UnsavedIssueAlertRule {
   createdBy: {email: string; id: number; name: string} | null;
   createdBy: {email: string; id: number; name: string} | null;
   dateCreated: string;
   dateCreated: string;
   id: string;
   id: string;
   projects: string[];
   projects: string[];
   errors?: {detail: string}[];
   errors?: {detail: string}[];
   lastTriggered?: string;
   lastTriggered?: string;
-};
+}
 
 
 // Project's alert rule stats
 // Project's alert rule stats
 export type ProjectAlertRuleStats = {
 export type ProjectAlertRuleStats = {

+ 12 - 12
static/app/types/breadcrumbs.tsx

@@ -29,36 +29,36 @@ export enum BreadcrumbType {
   INIT = 'init',
   INIT = 'init',
 }
 }
 
 
-type BreadcrumbTypeBase = {
+interface BreadcrumbTypeBase {
   level: BreadcrumbLevelType;
   level: BreadcrumbLevelType;
   // it's recommended
   // it's recommended
   category?: string | null;
   category?: string | null;
   event_id?: string | null;
   event_id?: string | null;
   message?: string;
   message?: string;
   timestamp?: string;
   timestamp?: string;
-};
+}
 
 
-export type BreadcrumbTypeSystem = {
+export interface BreadcrumbTypeSystem extends BreadcrumbTypeBase {
   action: string;
   action: string;
   extras: Record<string, any>;
   extras: Record<string, any>;
   type: BreadcrumbType.SYSTEM;
   type: BreadcrumbType.SYSTEM;
-} & BreadcrumbTypeBase;
+}
 
 
-export type BreadcrumbTypeSession = {
+export interface BreadcrumbTypeSession extends BreadcrumbTypeBase {
   action: string;
   action: string;
   extras: Record<string, any>;
   extras: Record<string, any>;
   type: BreadcrumbType.SESSION;
   type: BreadcrumbType.SESSION;
-} & BreadcrumbTypeBase;
+}
 
 
-export type BreadcrumbTypeNavigation = {
+export interface BreadcrumbTypeNavigation extends BreadcrumbTypeBase {
   type: BreadcrumbType.NAVIGATION;
   type: BreadcrumbType.NAVIGATION;
   data?: null | {
   data?: null | {
     from?: string;
     from?: string;
     to?: string;
     to?: string;
   };
   };
-} & BreadcrumbTypeBase;
+}
 
 
-export type BreadcrumbTypeHTTP = {
+export interface BreadcrumbTypeHTTP extends BreadcrumbTypeBase {
   type: BreadcrumbType.HTTP;
   type: BreadcrumbType.HTTP;
   data?: null | {
   data?: null | {
     method?:
     method?:
@@ -75,9 +75,9 @@ export type BreadcrumbTypeHTTP = {
     status_code?: number;
     status_code?: number;
     url?: string;
     url?: string;
   };
   };
-} & BreadcrumbTypeBase;
+}
 
 
-export type BreadcrumbTypeDefault = {
+export interface BreadcrumbTypeDefault extends BreadcrumbTypeBase {
   type:
   type:
     | BreadcrumbType.INFO
     | BreadcrumbType.INFO
     | BreadcrumbType.DEBUG
     | BreadcrumbType.DEBUG
@@ -93,7 +93,7 @@ export type BreadcrumbTypeDefault = {
     | BreadcrumbType.SYSTEM
     | BreadcrumbType.SYSTEM
     | BreadcrumbType.TRANSACTION;
     | BreadcrumbType.TRANSACTION;
   data?: Record<string, any> | null;
   data?: Record<string, any> | null;
-} & BreadcrumbTypeBase;
+}
 
 
 export type RawCrumb =
 export type RawCrumb =
   | BreadcrumbTypeNavigation
   | BreadcrumbTypeNavigation

+ 10 - 2
static/app/types/debugFiles.tsx

@@ -50,9 +50,17 @@ export type AppStoreConnectValidationError = {
     | 'app-connect-multiple-sources-error';
     | 'app-connect-multiple-sources-error';
 };
 };
 
 
+interface ValidAppStoreConnectCredentialsStatus {
+  status: 'valid';
+}
+
+interface InvalidAppStoreConnectCredentialsStatus extends AppStoreConnectValidationError {
+  status: 'invalid';
+}
+
 export type AppStoreConnectCredentialsStatus =
 export type AppStoreConnectCredentialsStatus =
-  | {status: 'valid'}
-  | ({status: 'invalid'} & AppStoreConnectValidationError);
+  | ValidAppStoreConnectCredentialsStatus
+  | InvalidAppStoreConnectCredentialsStatus;
 
 
 export type AppStoreConnectStatusData = {
 export type AppStoreConnectStatusData = {
   credentials: AppStoreConnectCredentialsStatus;
   credentials: AppStoreConnectCredentialsStatus;

+ 20 - 22
static/app/types/debugImage.tsx

@@ -94,11 +94,11 @@ export type CandidateDownload =
   | CandidateDownloadUnAppliedStatus
   | CandidateDownloadUnAppliedStatus
   | CandidateDownloadOtherStatus;
   | CandidateDownloadOtherStatus;
 
 
-type ImageCandidateBase = {
+interface ImageCandidateBase {
+  location: string;
   source: string;
   source: string;
-  location?: string;
   source_name?: string;
   source_name?: string;
-};
+}
 
 
 type InternalSource = {
 type InternalSource = {
   cpuName: string;
   cpuName: string;
@@ -110,35 +110,33 @@ type InternalSource = {
   symbolType: SymbolType;
   symbolType: SymbolType;
 };
 };
 
 
-export type ImageCandidateOk = ImageCandidateBase & {
+export interface ImageCandidateOk extends ImageCandidateBase {
   download: CandidateDownloadOkStatus;
   download: CandidateDownloadOkStatus;
   debug?: CandidateProcessingInfo;
   debug?: CandidateProcessingInfo;
   unwind?: CandidateProcessingInfo;
   unwind?: CandidateProcessingInfo;
-};
+}
 
 
-export type ImageCandidateInternalOk = ImageCandidateBase &
-  InternalSource & {
-    download: CandidateDownloadOkStatus;
-    debug?: CandidateProcessingInfo;
-    unwind?: CandidateProcessingInfo;
-  };
-
-export type ImageCandidateUnApplied = ImageCandidateBase &
-  InternalSource & {
-    download: CandidateDownloadUnAppliedStatus;
-    source: string;
-    source_name?: string;
-  };
-
-type ImageCandidateOthers = ImageCandidateBase & {
+export interface ImageCandidateInternalOk extends ImageCandidateBase, InternalSource {
+  download: CandidateDownloadOkStatus;
+  debug?: CandidateProcessingInfo;
+  unwind?: CandidateProcessingInfo;
+}
+
+export interface ImageCandidateUnApplied extends ImageCandidateBase, InternalSource {
+  download: CandidateDownloadUnAppliedStatus;
+  source: string;
+  source_name?: string;
+}
+
+interface ImageCandidateOthers extends ImageCandidateBase {
   download:
   download:
     | CandidateDownloadNotFoundStatus
     | CandidateDownloadNotFoundStatus
     | CandidateDownloadDeletedStatus
     | CandidateDownloadDeletedStatus
     | CandidateDownloadOtherStatus;
     | CandidateDownloadOtherStatus;
+  location: string;
   source: string;
   source: string;
-  location?: string;
   source_name?: string;
   source_name?: string;
-};
+}
 
 
 export type ImageCandidate =
 export type ImageCandidate =
   | ImageCandidateOk
   | ImageCandidateOk