Jelajahi Sumber

Removed useless 'as' typing on context state

jnfrati 5 tahun lalu
induk
melakukan
030d121fdd
1 mengubah file dengan 8 tambahan dan 8 penghapusan
  1. 8 8
      dashboard/src/shared/Context.tsx

+ 8 - 8
dashboard/src/shared/Context.tsx

@@ -51,13 +51,13 @@ export interface GlobalContextType {
  * 4) As a rule of thumb, Context should not be used for UI-related state
  * 4) As a rule of thumb, Context should not be used for UI-related state
  */
  */
 class ContextProvider extends Component<PropsType, StateType> {
 class ContextProvider extends Component<PropsType, StateType> {
-  state = {
-    currentModal: null as string | null,
-    currentModalData: null as any,
+  state: GlobalContextType = {
+    currentModal: null,
+    currentModalData: null,
     setCurrentModal: (currentModal: string, currentModalData?: any) => {
     setCurrentModal: (currentModal: string, currentModalData?: any) => {
       this.setState({ currentModal, currentModalData });
       this.setState({ currentModal, currentModalData });
     },
     },
-    currentError: null as string | null,
+    currentError: null,
     setCurrentError: (currentError: string) => {
     setCurrentError: (currentError: string) => {
       this.setState({ currentError });
       this.setState({ currentError });
     },
     },
@@ -78,7 +78,7 @@ class ContextProvider extends Component<PropsType, StateType> {
         callback && callback();
         callback && callback();
       });
       });
     },
     },
-    currentProject: null as ProjectType | null,
+    currentProject: null,
     setCurrentProject: (currentProject: ProjectType, callback?: any) => {
     setCurrentProject: (currentProject: ProjectType, callback?: any) => {
       pushQueryParams(this.props, { project_id: currentProject.id.toString() });
       pushQueryParams(this.props, { project_id: currentProject.id.toString() });
       if (currentProject) {
       if (currentProject) {
@@ -90,12 +90,12 @@ class ContextProvider extends Component<PropsType, StateType> {
         callback && callback();
         callback && callback();
       });
       });
     },
     },
-    projects: [] as ProjectType[],
+    projects: [],
     setProjects: (projects: ProjectType[]) => {
     setProjects: (projects: ProjectType[]) => {
       projects.sort((a: any, b: any) => (a.name > b.name ? 1 : -1));
       projects.sort((a: any, b: any) => (a.name > b.name ? 1 : -1));
       this.setState({ projects });
       this.setState({ projects });
     },
     },
-    user: null as any,
+    user: null,
     setUser: (userId: number, email: string) => {
     setUser: (userId: number, email: string) => {
       this.setState({ user: { userId, email } });
       this.setState({ user: { userId, email } });
     },
     },
@@ -103,7 +103,7 @@ class ContextProvider extends Component<PropsType, StateType> {
     setDevOpsMode: (devOpsMode: boolean) => {
     setDevOpsMode: (devOpsMode: boolean) => {
       this.setState({ devOpsMode });
       this.setState({ devOpsMode });
     },
     },
-    capabilities: null as CapabilityType,
+    capabilities: null,
     setCapabilities: (capabilities: CapabilityType) => {
     setCapabilities: (capabilities: CapabilityType) => {
       this.setState({ capabilities });
       this.setState({ capabilities });
     },
     },