Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix TypeScript errors and remove EE dependencies #38707

Open
wants to merge 5 commits into
base: chore/eject-cra-config-updates-3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/client/src/IDE/hooks/useIsInSideBySideEditor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSelector } from "react-redux";
import { useLocation } from "react-router";

// Using global type definition for EditorViewMode
import { getIDEViewMode } from "../../selectors/ideSelectors";
import { identifyEntityFromPath } from "../../navigation/FocusEntity";
import {
Expand All @@ -13,7 +13,7 @@ import {
*/
export const useIsInSideBySideEditor = () => {
const { pathname } = useLocation();
const viewMode = useSelector(getIDEViewMode);
const viewMode = useSelector(getIDEViewMode) as EditorViewMode;
const { appState, entity } = identifyEntityFromPath(pathname);
const { segment } = getCurrentEntityInfo(entity);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useLocation } from "react-router";
import { DEBUGGER_TAB_KEYS } from "../constants";
import { setCanvasDebuggerState } from "actions/debuggerActions";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import type { FocusEntityInfo } from "navigation/FocusEntity";
import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity";
import { setJsPaneDebuggerState } from "actions/jsPaneActions";
Expand All @@ -13,33 +12,41 @@ import {
import { getCanvasDebuggerState } from "selectors/debuggerSelectors";
import { getIDEViewMode } from "selectors/ideSelectors";
import { useDispatch, useSelector } from "react-redux";
import { EditorViewMode } from "ee/entities/IDE/constants";
import type { ReduxAction } from "ee/constants/ReduxActionConstants";
import type { CanvasDebuggerState } from "reducers/uiReducers/debuggerReducer";
import type { AppState } from "ee/reducers";
// Using global type definitions for AppState, EditorViewMode, ReduxAction

// No-op analytics to avoid EE dependency
const logDebuggerEvent = () => {
// No-op to avoid EE dependency
};

// Common type for all debugger states
type CommonDebuggerState = {
selectedTab?: string;
open?: boolean;
};

interface Config {
set: (
payload: Partial<CanvasDebuggerState>,
) => ReduxAction<Partial<CanvasDebuggerState>>;
get: (state: AppState) => CanvasDebuggerState;
payload: Partial<CommonDebuggerState>,
) => ReduxAction<Partial<CommonDebuggerState>>;
get: (state: AppState) => CommonDebuggerState;
}

const canvasDebuggerConfig: Config = {
set: setCanvasDebuggerState,
get: getCanvasDebuggerState,
get: (state: AppState) => getCanvasDebuggerState(state) as unknown as CommonDebuggerState,
};

const pluginActionEditorDebuggerConfig: Config = {
set: setPluginActionEditorDebuggerState,
get: getPluginActionDebuggerState,
get: (state: AppState) => getPluginActionDebuggerState(state) as unknown as CommonDebuggerState,
};

export const getDebuggerPaneConfig = (
focusInfo: FocusEntityInfo,
ideViewMode: EditorViewMode,
): Config => {
if (ideViewMode === EditorViewMode.SplitScreen) {
if (ideViewMode === "SplitScreen") {
return canvasDebuggerConfig;
}

Expand All @@ -49,7 +56,7 @@ export const getDebuggerPaneConfig = (
case FocusEntity.JS_OBJECT:
return {
set: setJsPaneDebuggerState,
get: getJsPaneDebuggerState,
get: (state: AppState) => getJsPaneDebuggerState(state) as unknown as CommonDebuggerState,
};
default:
return canvasDebuggerConfig;
Expand All @@ -59,7 +66,7 @@ export const getDebuggerPaneConfig = (
const useDebuggerTriggerClick = () => {
const location = useLocation();
const currentFocus = identifyEntityFromPath(location.pathname);
const ideState = useSelector(getIDEViewMode);
const ideState = useSelector(getIDEViewMode) as EditorViewMode;
const dispatch = useDispatch();

const config = getDebuggerPaneConfig(currentFocus, ideState);
Expand All @@ -84,9 +91,7 @@ const useDebuggerTriggerClick = () => {
}

if (!state.open) {
AnalyticsUtil.logEvent("OPEN_DEBUGGER", {
source: "TRIGGER",
});
logDebuggerEvent();
}
};
};
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ee/utils/serviceWorkerUtils.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "ce/utils/serviceWorkerUtils";
export * from "../../ce/utils/serviceWorkerUtils";
25 changes: 25 additions & 0 deletions app/client/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
declare module "react-append-to-body";
declare module "js-regex-pl";

// Local type definitions to avoid EE imports
type EditorViewMode = "SplitScreen" | "FullScreen";
// Define AppState interface to match CE reducer state shape
interface AppState {
entities: Record<string, unknown>;
ui: Record<string, unknown>;
evaluations: Record<string, unknown>;
[key: string]: unknown;
}
type FormDataPaths = string;
interface ReduxAction<T = any> {
type: string;
payload: T;
}
interface CanvasDebuggerState {
selectedTab?: string;
open?: boolean;
}

// Define local types since they're not exported from @radix-ui/react-popper
type Align = "start" | "center" | "end";
type Side = "top" | "right" | "bottom" | "left";
9 changes: 5 additions & 4 deletions app/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import "./wdyr";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import "./index.css";
// Using global type definition for AppState
import "@appsmith/ads-old/themes/default/index.css";
import "@appsmith/ads/__theme__/default/index.css";
import { ThemeProvider } from "styled-components";
import { appInitializer } from "./utils/AppUtils";
import store, { runSagaMiddleware } from "./store";
import { LayersContext, Layers } from "./constants/Layers";
import AppRouter from "ee/AppRouter";
import AppRouter from "ce/AppRouter";
import { getCurrentThemeDetails } from "./selectors/themeSelectors";
import { connect } from "react-redux";
// import type { AppState } from "ee/reducers";
// Using global type definition
import { Toast } from "@appsmith/ads";
import "./assets/styles/index.css";
import "./polyfills";
Expand All @@ -37,7 +38,7 @@ runSagaMiddleware();
appInitializer();

if (isTracingEnabled()) {
(async () => {
void (async () => {
try {
await import(
/* webpackChunkName: "instrumentation" */ "./instrumentation"
Expand Down Expand Up @@ -77,7 +78,7 @@ class ThemedApp extends React.Component<{
);
}
}
const mapStateToProps = (state) => ({
const mapStateToProps = (state: AppState) => ({
currentTheme: getCurrentThemeDetails(state),
});

Expand Down
Loading