Browse Source

fix(reflux): fix types so we stop casting (#33217)

Jonas 2 years ago
parent
commit
fab1c22ce8

+ 1 - 2
static/app/stores/alertStore.tsx

@@ -111,6 +111,5 @@ const storeConfig: AlertStoreDefinition = {
   },
 };
 
-const AlertStore = createStore(storeConfig) as Reflux.Store & AlertStoreDefinition;
-
+const AlertStore = createStore(storeConfig);
 export default AlertStore;

+ 2 - 4
static/app/stores/committerStore.tsx

@@ -2,7 +2,7 @@ import {createStore} from 'reflux';
 
 import CommitterActions from 'sentry/actions/committerActions';
 import {Committer} from 'sentry/types';
-import {makeSafeRefluxStore, SafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
+import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
 
 type State = {
   // Use `getCommitterStoreKey` to generate key
@@ -107,7 +107,5 @@ export function getCommitterStoreKey(
   return `${orgSlug} ${projectSlug} ${eventId}`;
 }
 
-const CommitterStore = createStore(makeSafeRefluxStore(storeConfig)) as SafeRefluxStore &
-  CommitterStoreDefinition;
-
+const CommitterStore = createStore(makeSafeRefluxStore(storeConfig));
 export default CommitterStore;

+ 2 - 3
static/app/stores/configStore.tsx

@@ -2,7 +2,7 @@ import moment from 'moment-timezone';
 import {createStore} from 'reflux';
 
 import {Config} from 'sentry/types';
-import {makeSafeRefluxStore, SafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
+import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
 
 import {CommonStoreDefinition} from './types';
 
@@ -81,5 +81,4 @@ const storeConfig: ConfigStoreDefinition = {
   },
 };
 
-export default createStore(makeSafeRefluxStore(storeConfig)) as SafeRefluxStore &
-  ConfigStoreDefinition;
+export default createStore(makeSafeRefluxStore(storeConfig));

+ 2 - 7
static/app/stores/debugMetaStore.tsx

@@ -1,10 +1,6 @@
 import {createActions, createStore, StoreDefinition} from 'reflux';
 
-import {
-  makeSafeRefluxStore,
-  SafeRefluxStore,
-  SafeStoreDefinition,
-} from 'sentry/utils/makeSafeRefluxStore';
+import {makeSafeRefluxStore, SafeStoreDefinition} from 'sentry/utils/makeSafeRefluxStore';
 
 const DebugMetaActions = createActions(['updateFilter']);
 
@@ -55,8 +51,7 @@ const storeConfig: StoreDefinition &
   },
 };
 
-const DebugMetaStore = createStore(makeSafeRefluxStore(storeConfig)) as SafeRefluxStore &
-  DebugMetaStoreInterface;
+const DebugMetaStore = createStore(makeSafeRefluxStore(storeConfig));
 
 export {DebugMetaActions, DebugMetaStore};
 export default DebugMetaStore;

+ 2 - 4
static/app/stores/eventStore.tsx

@@ -3,7 +3,7 @@ import isArray from 'lodash/isArray';
 import {createStore, StoreDefinition} from 'reflux';
 
 import {Event} from 'sentry/types/event';
-import {makeSafeRefluxStore, SafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
+import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
 
 type InternalDefinition = {
   items: Event[];
@@ -99,7 +99,5 @@ const storeConfig: EventStoreDefinition = {
   },
 };
 
-const EventStore = createStore(makeSafeRefluxStore(storeConfig)) as SafeRefluxStore &
-  EventStoreDefinition;
-
+const EventStore = createStore(makeSafeRefluxStore(storeConfig));
 export default EventStore;

+ 2 - 5
static/app/stores/externalIssueStore.tsx

@@ -1,7 +1,7 @@
 import {createStore, StoreDefinition} from 'reflux';
 
 import {PlatformExternalIssue} from 'sentry/types';
-import {makeSafeRefluxStore, SafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
+import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
 
 interface ExternalIssueStoreDefinition extends StoreDefinition {
   add(issue: PlatformExternalIssue): void;
@@ -39,8 +39,5 @@ const storeConfig: ExternalIssueStoreDefinition = {
   },
 };
 
-const ExternalIssueStore = createStore(
-  makeSafeRefluxStore(storeConfig)
-) as SafeRefluxStore & ExternalIssueStoreDefinition;
-
+const ExternalIssueStore = createStore(makeSafeRefluxStore(storeConfig));
 export default ExternalIssueStore;

+ 8 - 7
static/app/stores/formSearchStore.tsx

@@ -1,4 +1,4 @@
-import {createStore, Store} from 'reflux';
+import {createStore} from 'reflux';
 
 import FormSearchActions from 'sentry/actions/formSearchActions';
 import {FieldObject} from 'sentry/components/forms/type';
@@ -14,17 +14,20 @@ export type FormSearchField = {
   title: React.ReactNode;
 };
 
-type StoreInterface = {
+interface StoreInterface {
   get(): InternalDefinition['searchMap'];
   reset(): void;
-};
+}
 
 type InternalDefinition = {
   onLoadSearchMap: (searchMap: null | FormSearchField[]) => void;
   searchMap: null | FormSearchField[];
 };
 
-interface ExternalIssuesDefinition extends SafeStoreDefinition, InternalDefinition {}
+interface ExternalIssuesDefinition
+  extends SafeStoreDefinition,
+    InternalDefinition,
+    StoreInterface {}
 
 /**
  * Store for "form" searches, but probably will include more
@@ -63,7 +66,5 @@ const storeConfig: ExternalIssuesDefinition = {
   },
 };
 
-const FormSearchStore = createStore(makeSafeRefluxStore(storeConfig)) as Store &
-  StoreInterface;
-
+const FormSearchStore = createStore(makeSafeRefluxStore(storeConfig));
 export default FormSearchStore;

+ 4 - 6
static/app/stores/groupStore.tsx

@@ -13,7 +13,7 @@ import {
   GroupRelease,
   GroupStats,
 } from 'sentry/types';
-import {makeSafeRefluxStore, SafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
+import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
 
 function showAlert(msg, type) {
   IndicatorStore.addMessage(msg, type, {duration: 4000});
@@ -57,7 +57,7 @@ interface InternalDefinition {
   updateActivity: (groupId: string, id: string, data: Partial<Activity>) => void;
 }
 
-interface GroupStoreDefintion extends StoreDefinition, InternalDefinition {
+interface GroupStoreDefinition extends StoreDefinition, InternalDefinition {
   add: (items: Item[]) => void;
   addStatus: (id: string, status: string) => void;
   clearStatus: (id: string, status: string) => void;
@@ -97,7 +97,7 @@ interface GroupStoreDefintion extends StoreDefinition, InternalDefinition {
   reset: () => void;
 }
 
-const storeConfig: GroupStoreDefintion = {
+const storeConfig: GroupStoreDefinition = {
   listenables: [GroupActions],
   pendingChanges: new PendingChangeQueue(),
   items: [],
@@ -519,7 +519,5 @@ const storeConfig: GroupStoreDefintion = {
   },
 };
 
-const GroupStore = createStore(makeSafeRefluxStore(storeConfig)) as SafeRefluxStore &
-  GroupStoreDefintion;
-
+const GroupStore = createStore(makeSafeRefluxStore(storeConfig));
 export default GroupStore;

+ 2 - 4
static/app/stores/groupingStore.tsx

@@ -11,7 +11,7 @@ import GroupingActions from 'sentry/actions/groupingActions';
 import {Client} from 'sentry/api';
 import {Group, Organization, Project} from 'sentry/types';
 import {Event} from 'sentry/types/event';
-import {makeSafeRefluxStore, SafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
+import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
 
 // Between 0-100
 const MIN_SCORE = 0.6;
@@ -617,7 +617,5 @@ const storeConfig: GroupingStoreDefinition = {
   },
 };
 
-const GroupingStore = createStore(makeSafeRefluxStore(storeConfig)) as SafeRefluxStore &
-  GroupingStoreDefinition;
-
+const GroupingStore = createStore(makeSafeRefluxStore(storeConfig));
 export default GroupingStore;

+ 1 - 4
static/app/stores/guideStore.tsx

@@ -10,7 +10,6 @@ import {trackAnalyticsEvent} from 'sentry/utils/analytics';
 import {
   cleanupActiveRefluxSubscriptions,
   makeSafeRefluxStore,
-  SafeRefluxStore,
 } from 'sentry/utils/makeSafeRefluxStore';
 
 function guidePrioritySort(a: Guide, b: Guide) {
@@ -289,7 +288,5 @@ const storeConfig: GuideStoreDefinition = {
   },
 };
 
-const GuideStore = createStore(makeSafeRefluxStore(storeConfig)) as SafeRefluxStore &
-  GuideStoreDefinition;
-
+const GuideStore = createStore(makeSafeRefluxStore(storeConfig));
 export default GuideStore;

Some files were not shown because too many files changed in this diff