Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgrzybowski committed Jan 18, 2024
1 parent 1c1062e commit 3d29b64
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import linkingConfig from './linkingConfig';
import customGetPathFromState from './linkingConfig/customGetPathFromState';
import getAdaptedStateFromPath from './linkingConfig/getAdaptedStateFromPath';
import Navigation, {navigationRef} from './Navigation';
import {RootStackParamList} from './types';

Check failure on line 19 in src/libs/Navigation/NavigationRoot.tsx

View workflow job for this annotation

GitHub Actions / lint

All imports in the declaration are only used as types. Use `import type`

type NavigationRootProps = {
/** Whether the current user is logged in with an authToken */
Expand Down Expand Up @@ -110,7 +111,7 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
if (!state) {
return;
}
const activeWorkspaceID = getPolicyIdFromState(state);
const activeWorkspaceID = getPolicyIdFromState(state as NavigationState<RootStackParamList>);
// Performance optimization to avoid context consumers to delay first render
setTimeout(() => {
currentReportIDValue?.updateCurrentReportID(state);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/getPolicyIdFromState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import getTopmostBottomTabRoute from './getTopmostBottomTabRoute';
import type {State} from './types';
import type {RootStackParamList, State} from './types';

const getPolicyIdFromState = (state: State) => {
const getPolicyIdFromState = (state: State<RootStackParamList>) => {
const topmostBottomTabRoute = getTopmostBottomTabRoute(state);

const shouldAddPolicyIdToUrl = !!topmostBottomTabRoute && !!topmostBottomTabRoute.params && 'policyID' in topmostBottomTabRoute.params && !!topmostBottomTabRoute.params?.policyID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SCREENS from '@src/SCREENS';

const customGetPathFromState: typeof getPathFromState = (state, options) => {
const path = getPathFromState(state, options);
const policyIDFromState = getPolicyIdFromState(state);
const policyIDFromState = getPolicyIdFromState(state as State<RootStackParamList>);
const isWorkspaceSettingsOpened = getTopmostBottomTabRoute(state as State<RootStackParamList>)?.name === SCREENS.WORKSPACE.INITIAL && path.includes('workspace');
return `${policyIDFromState && !isWorkspaceSettingsOpened ? `/w/${policyIDFromState}` : ''}${path}`;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const addPolicyIdToRoute = (route: NavigationPartialRoute, policyID?: string) =>
return routeWithPolicyID;
}

// @ts-expect-error TODO: fix this type
routeWithPolicyID.params.policyID = policyID;

return routeWithPolicyID;
Expand Down

0 comments on commit 3d29b64

Please sign in to comment.