diff --git a/app/client/src/ce/workers/Evaluation/evaluationUtils.test.ts b/app/client/src/ce/workers/Evaluation/evaluationUtils.test.ts index 538663cf19..802feace21 100644 --- a/app/client/src/ce/workers/Evaluation/evaluationUtils.test.ts +++ b/app/client/src/ce/workers/Evaluation/evaluationUtils.test.ts @@ -626,9 +626,10 @@ describe("5. overrideWidgetProperties", () => { }); // When default text is re-evaluated it will override values of meta.text and text in InputWidget it("1. defaultText updating meta.text and text", () => { + const widgetEntity = currentTree.Input1 as WidgetEntity; const evalMetaUpdates: EvalMetaUpdates = []; const overwriteObj = overrideWidgetProperties({ - entity: currentTree.Input1 as WidgetEntity, + entity: widgetEntity, propertyPath: "defaultText", value: "abcde", @@ -643,30 +644,28 @@ describe("5. overrideWidgetProperties", () => { expect(evalMetaUpdates).toStrictEqual([ { - //@ts-expect-error: widgetId does not exits on type DataTreeEntity - widgetId: currentTree.Input1.widgetId, + widgetId: widgetEntity.widgetId, metaPropertyPath: ["inputText"], value: "abcde", }, { - //@ts-expect-error: widgetId does not exits on type DataTreeEntity - widgetId: currentTree.Input1.widgetId, + widgetId: widgetEntity.widgetId, metaPropertyPath: ["text"], value: "abcde", }, ]); - //@ts-expect-error: meta does not exits on type DataTreeEntity - expect(currentTree.Input1.meta).toStrictEqual({ + expect(widgetEntity.meta).toStrictEqual({ text: "abcde", inputText: "abcde", }); }); // When meta.text is re-evaluated it will override values text in InputWidget it("2. meta.text updating text", () => { + const widgetEntity = currentTree.Input1 as WidgetEntity; const evalMetaUpdates: EvalMetaUpdates = []; const overwriteObj = overrideWidgetProperties({ - entity: currentTree.Input1 as WidgetEntity, + entity: widgetEntity, propertyPath: "meta.text", value: "abcdefg", currentTree, @@ -680,8 +679,7 @@ describe("5. overrideWidgetProperties", () => { expect(evalMetaUpdates).toStrictEqual([]); - //@ts-expect-error: text does not exits on type DataTreeEntity - expect(currentTree.Input1.text).toStrictEqual("abcdefg"); + expect(widgetEntity.text).toStrictEqual("abcdefg"); }); }); @@ -713,9 +711,10 @@ describe("5. overrideWidgetProperties", () => { }); // When default defaultSelectedRow is re-evaluated it will override values of meta.selectedRowIndices, selectedRowIndices, meta.selectedRowIndex & selectedRowIndex. it("1. On change of defaultSelectedRow ", () => { + const widgetEntity = currentTree.Table1 as WidgetEntity; const evalMetaUpdates: EvalMetaUpdates = []; const overwriteObj = overrideWidgetProperties({ - entity: currentTree.Table1 as WidgetEntity, + entity: widgetEntity, propertyPath: "defaultSelectedRow", value: [0, 1], currentTree, @@ -729,29 +728,27 @@ describe("5. overrideWidgetProperties", () => { expect(evalMetaUpdates).toStrictEqual([ { - //@ts-expect-error: widgetId does not exits on type DataTreeEntity - widgetId: currentTree.Table1.widgetId, + widgetId: widgetEntity.widgetId, metaPropertyPath: ["selectedRowIndex"], value: [0, 1], }, { - //@ts-expect-error: widgetId does not exits on type DataTreeEntity - widgetId: currentTree.Table1.widgetId, + widgetId: widgetEntity.widgetId, metaPropertyPath: ["selectedRowIndices"], value: [0, 1], }, ]); - //@ts-expect-error: meta does not exits on type DataTreeEntity - expect(currentTree.Table1.meta.selectedRowIndex).toStrictEqual([0, 1]); - //@ts-expect-error: meta does not exits on type DataTreeEntity - expect(currentTree.Table1.meta.selectedRowIndices).toStrictEqual([0, 1]); + expect(widgetEntity.meta.selectedRowIndex).toStrictEqual([0, 1]); + + expect(widgetEntity.meta.selectedRowIndices).toStrictEqual([0, 1]); }); // When meta.selectedRowIndex is re-evaluated it will override values selectedRowIndex it("2. meta.selectedRowIndex updating selectedRowIndex", () => { + const widgetEntity = currentTree.Table1 as WidgetEntity; const evalMetaUpdates: EvalMetaUpdates = []; const overwriteObj = overrideWidgetProperties({ - entity: currentTree.Table1 as WidgetEntity, + entity: widgetEntity, propertyPath: "meta.selectedRowIndex", value: 0, currentTree, @@ -765,8 +762,7 @@ describe("5. overrideWidgetProperties", () => { expect(evalMetaUpdates).toStrictEqual([]); - //@ts-expect-error: selectedRowIndex does not exits on type DataTreeEntity - expect(currentTree.Table1.selectedRowIndex).toStrictEqual(0); + expect(widgetEntity.selectedRowIndex).toStrictEqual(0); }); }); }); diff --git a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts index c48595c2b8..783ae2391f 100644 --- a/app/client/src/ce/workers/Evaluation/evaluationUtils.ts +++ b/app/client/src/ce/workers/Evaluation/evaluationUtils.ts @@ -737,7 +737,9 @@ const getDataTreeWithoutSuppressedAutoComplete = ( ): DataTree => { const entityIds = Object.keys(dataTree).filter((entityName) => { const entity = dataTree[entityName]; - return isWidget(entity) && shouldSuppressAutoComplete(entity); + return ( + isWidget(entity) && shouldSuppressAutoComplete(entity as WidgetEntity) + ); }); return _.omit(dataTree, entityIds); diff --git a/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts b/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts index 94cc34b3ab..74c4c45ce9 100644 --- a/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts +++ b/app/client/src/components/editorComponents/Debugger/hooks/debuggerHooks.ts @@ -24,6 +24,7 @@ import history, { NavigationMethod } from "utils/history"; import { jsCollectionIdURL } from "@appsmith/RouteBuilder"; import store from "store"; import { PluginType } from "entities/Action"; +import type { WidgetEntity } from "@appsmith/entities/DataTree/types"; export const useFilteredLogs = (query: string, filter?: any) => { let logs = useSelector((state: AppState) => state.ui.debugger.logs); @@ -141,8 +142,9 @@ export const useEntityLink = () => { const entityConfig = configTree[name]; if (!pageId) return; if (isWidget(entity)) { + const widgetEntity = entity as WidgetEntity; navigateToWidget( - entity.widgetId, + widgetEntity.widgetId, entity.type, pageId || "", NavigationMethod.Debugger, diff --git a/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx b/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx index efec5cdfa6..53c17e66dd 100644 --- a/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx +++ b/app/client/src/components/editorComponents/Debugger/hooks/useGetEntityInfo.tsx @@ -16,6 +16,7 @@ import { import { doesEntityHaveErrors } from "../helpers"; import React from "react"; import WidgetIcon from "pages/Editor/Explorer/Widgets/WidgetIcon"; +import type { WidgetEntity } from "@appsmith/entities/DataTree/types"; export const useGetEntityInfo = (name: string) => { const entity = useSelector((state: AppState) => state.evaluations.tree[name]); @@ -36,15 +37,19 @@ export const useGetEntityInfo = (name: string) => { const getEntityInfo = useCallback(() => { if (isWidget(entity)) { + const widgetEntity = entity as WidgetEntity; const icon = ; - const hasError = doesEntityHaveErrors(entity.widgetId, debuggerErrors); + const hasError = doesEntityHaveErrors( + widgetEntity.widgetId, + debuggerErrors, + ); return { name, icon, hasError, type: ENTITY_TYPE.WIDGET, - entityType: entity.type, + entityType: widgetEntity.type, }; } else if (isAction(entity)) { const hasError = doesEntityHaveErrors(entity.actionId, debuggerErrors); diff --git a/app/client/src/plugins/Linting/lib/entity/index.ts b/app/client/src/plugins/Linting/lib/entity/index.ts index 3c99d5a5ec..333afb7290 100644 --- a/app/client/src/plugins/Linting/lib/entity/index.ts +++ b/app/client/src/plugins/Linting/lib/entity/index.ts @@ -49,31 +49,33 @@ export default class EntityFactory { T extends DataTreeEntity, K extends DataTreeEntityConfig | undefined, >(entity: T, config: K, classLoader: EntityClassLoader): IEntity { - const { DiffGenerator, Parser } = classLoader.load(entity); + const { DiffGenerator, Parser } = classLoader.load( + entity as DataTreeEntity, + ); if (isWidget(entity)) { return new WidgetEntity( - entity, + entity as TWidgetEntity, config as TWidgetEntityConfig, new Parser(), new DiffGenerator(), ); } else if (isJSAction(entity)) { return new JSEntity( - entity, + entity as TJSActionEntity, config as TJSActionEntityConfig, new Parser(), new DiffGenerator(), ); } else if (isAction(entity)) { return new ActionEntity( - entity, + entity as TActionEntity, config as TActionEntityConfig, new Parser(), new DiffGenerator(), ); } else if (isAppsmith(entity)) { return new AppsmithEntity( - entity, + entity as TAppsmithEntity, undefined, new Parser(), new DiffGenerator(), diff --git a/app/client/src/sagas/ActionExecution/ResetWidgetActionSaga.ts b/app/client/src/sagas/ActionExecution/ResetWidgetActionSaga.ts index 117b624c31..e71fce0013 100644 --- a/app/client/src/sagas/ActionExecution/ResetWidgetActionSaga.ts +++ b/app/client/src/sagas/ActionExecution/ResetWidgetActionSaga.ts @@ -13,7 +13,10 @@ import { getType, Types } from "utils/TypeHelpers"; import type { FlattenedWidgetProps } from "WidgetProvider/constants"; import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants"; import { getDataTree, getConfigTree } from "selectors/dataTreeSelectors"; -import type { WidgetEntityConfig } from "@appsmith/entities/DataTree/types"; +import type { + WidgetEntity, + WidgetEntityConfig, +} from "@appsmith/entities/DataTree/types"; import type { DataTree, ConfigTree } from "entities/DataTree/dataTreeTypes"; import { isWidget } from "@appsmith/workers/Evaluation/evaluationUtils"; import type { TResetWidgetDescription } from "workers/Evaluation/fns/resetWidget"; @@ -47,7 +50,7 @@ export default function* resetWidgetActionSaga( yield put( resetWidgetMetaProperty( widget.widgetId, - evaluatedEntity, + evaluatedEntity as WidgetEntity, evaluatedEntityConfig as WidgetEntityConfig, ), ); diff --git a/app/client/src/sagas/DebuggerSagas.ts b/app/client/src/sagas/DebuggerSagas.ts index a8d370a88b..e837cb9eef 100644 --- a/app/client/src/sagas/DebuggerSagas.ts +++ b/app/client/src/sagas/DebuggerSagas.ts @@ -64,6 +64,10 @@ import { isWidget, } from "@appsmith/workers/Evaluation/evaluationUtils"; import { getCurrentEnvironmentDetails } from "@appsmith/selectors/environmentSelectors"; +import type { + ActionEntity, + WidgetEntity, +} from "@appsmith/entities/DataTree/types"; import { getActiveEditorField } from "selectors/activeEditorFieldSelectors"; let blockedSource: string | null = null; @@ -186,23 +190,25 @@ function getLogsFromDependencyChain( }; if (isAction(entity)) { + const actionEntity = entity as ActionEntity; log = { ...log, text: createMessage(ACTION_CONFIGURATION_UPDATED), source: { type: ENTITY_TYPE.ACTION, name: entityInfo.entityName, - id: entity.actionId, + id: actionEntity.actionId, }, }; } else if (isWidget(entity)) { + const widgetEntity = entity as WidgetEntity; log = { ...log, text: createMessage(WIDGET_PROPERTIES_UPDATED), source: { type: ENTITY_TYPE.WIDGET, name: entityInfo.entityName, - id: entity.widgetId, + id: widgetEntity.widgetId, }, }; } diff --git a/app/client/src/sagas/PostEvaluationSagas.ts b/app/client/src/sagas/PostEvaluationSagas.ts index 19c305877f..d01c6da279 100644 --- a/app/client/src/sagas/PostEvaluationSagas.ts +++ b/app/client/src/sagas/PostEvaluationSagas.ts @@ -4,7 +4,12 @@ import { PLATFORM_ERROR, Severity, } from "entities/AppsmithConsole"; -import type { WidgetEntityConfig } from "@appsmith/entities/DataTree/types"; +import type { + ActionEntity, + JSActionEntity, + WidgetEntity, + WidgetEntityConfig, +} from "@appsmith/entities/DataTree/types"; import type { ConfigTree, DataTree, @@ -75,7 +80,10 @@ function logLatestEvalPropertyErrors( for (const evaluatedPath of evalAndValidationOrder) { const { entityName, propertyPath } = getEntityNameAndPropertyPath(evaluatedPath); - const entity = dataTree[entityName]; + const entity = dataTree[entityName] as + | WidgetEntity + | ActionEntity + | JSActionEntity; const entityConfig = configTree[entityName] as any; if (isWidget(entity) || isAction(entity) || isJSAction(entity)) { @@ -490,7 +498,10 @@ export function* updateTernDefinitions( ); const entity = dataTree[entityName]; if (!entity || !isWidget(entity)) return false; - return isWidgetPropertyNamePath(entity, update.payload.propertyPath); + return isWidgetPropertyNamePath( + entity as WidgetEntity, + update.payload.propertyPath, + ); }); if (!shouldUpdate) return; diff --git a/app/client/src/selectors/debuggerSelectors.tsx b/app/client/src/selectors/debuggerSelectors.tsx index 3e2ef092a9..f9f36e245a 100644 --- a/app/client/src/selectors/debuggerSelectors.tsx +++ b/app/client/src/selectors/debuggerSelectors.tsx @@ -46,22 +46,24 @@ export const getFilteredErrors = createSelector( // filter error - when widget or parent widget is hidden // parent widgets e.g. modal, tab, container if (entity && isWidget(entity)) { - if (shouldSuppressDebuggerError(entity)) { + const widgetEntity = entity as WidgetEntity; + if (shouldSuppressDebuggerError(widgetEntity)) { return false; } - if (!hasParentWidget(entity)) { - return entity.isVisible + if (!hasParentWidget(widgetEntity)) { + return widgetEntity.isVisible ? true - : alwaysShowEntities[entity.widgetId]; + : alwaysShowEntities[widgetEntity.widgetId]; } else { const isParentWidgetVisible = isParentVisible( - entity, + widgetEntity, canvasWidgets, dataTree, ); - return entity.isVisible + return widgetEntity.isVisible ? isParentWidgetVisible - : isParentWidgetVisible && alwaysShowEntities[entity.widgetId]; + : isParentWidgetVisible && + alwaysShowEntities[widgetEntity.widgetId]; } } return true; diff --git a/app/client/src/utils/autocomplete/dataTreeTypeDefCreator.ts b/app/client/src/utils/autocomplete/dataTreeTypeDefCreator.ts index eb9fb4ea37..fc72acddc1 100644 --- a/app/client/src/utils/autocomplete/dataTreeTypeDefCreator.ts +++ b/app/client/src/utils/autocomplete/dataTreeTypeDefCreator.ts @@ -1,6 +1,7 @@ import type { WidgetEntityConfig, JSActionEntityConfig, + WidgetEntity, } from "@appsmith/entities/DataTree/types"; import type { ConfigTree, @@ -57,7 +58,7 @@ export const dataTreeTypeDefCreator = ( if (isFunction(autocompleteDefinitions)) { def[entityName] = autocompleteDefinitions( - entity, + entity as WidgetEntity, extraDefsToDefine, entityConfig, ); diff --git a/app/client/src/workers/Evaluation/fns/index.ts b/app/client/src/workers/Evaluation/fns/index.ts index c0d56d0ff7..ff6ab3316c 100644 --- a/app/client/src/workers/Evaluation/fns/index.ts +++ b/app/client/src/workers/Evaluation/fns/index.ts @@ -119,10 +119,11 @@ export const entityFns = [ name: "run", qualifier: (entity: DataTreeEntity) => isAction(entity), fn: (entity: DataTreeEntity, entityName: string) => { + const actionEntity = entity as ActionEntity; // @ts-expect-error: name is not defined on ActionEntity - entity.name = entityName; + actionEntity.name = entityName; return getFnWithGuards( - run.bind(entity as ActionEntity), + run.bind(actionEntity as ActionEntity), `${entityName}.run`, [isAsyncGuard], ); diff --git a/app/client/src/workers/Evaluation/getEntityForContext.ts b/app/client/src/workers/Evaluation/getEntityForContext.ts index 8037878d76..39cebc5e69 100644 --- a/app/client/src/workers/Evaluation/getEntityForContext.ts +++ b/app/client/src/workers/Evaluation/getEntityForContext.ts @@ -39,7 +39,7 @@ export function getEntityForEvalContext( switch (entity.ENTITY_TYPE) { case ENTITY_TYPE_VALUE.JSACTION: { const jsObjectName = entityName; - const jsObject = entity; + const jsObject = entity as JSActionEntity; let jsObjectForEval = JSObjectCollection.getVariableState(entityName); diff --git a/app/client/src/workers/Evaluation/setters.ts b/app/client/src/workers/Evaluation/setters.ts index b9b089f107..4b73c30195 100644 --- a/app/client/src/workers/Evaluation/setters.ts +++ b/app/client/src/workers/Evaluation/setters.ts @@ -8,7 +8,10 @@ import { evalTreeWithChanges } from "./evalTreeWithChanges"; import { dataTreeEvaluator } from "./handlers/evalTree"; import { get, set } from "lodash"; import { validate } from "./validations"; -import type { DataTreeEntityConfig } from "@appsmith/entities/DataTree/types"; +import type { + DataTreeEntityConfig, + WidgetEntity, +} from "@appsmith/entities/DataTree/types"; import type { ConfigTree, DataTree, @@ -89,7 +92,7 @@ class Setters { if (isWidget(entity)) { overrideWidgetProperties({ - entity, + entity: entity as WidgetEntity, propertyPath, value: parsedValue, currentTree: evalTree, diff --git a/app/client/src/workers/common/DataTreeEvaluator/index.ts b/app/client/src/workers/common/DataTreeEvaluator/index.ts index 2b536045a5..4b420a9c5e 100644 --- a/app/client/src/workers/common/DataTreeEvaluator/index.ts +++ b/app/client/src/workers/common/DataTreeEvaluator/index.ts @@ -1046,9 +1046,7 @@ export default class DataTreeEvaluator { ); const entityType = entityConfig.ENTITY_TYPE; - if (!propertyPath) continue; - switch (entityType) { case ENTITY_TYPE_VALUE.WIDGET: { if (isATriggerPath) continue; @@ -1278,7 +1276,7 @@ export default class DataTreeEvaluator { const node = result.cyclicNode; let entityType = "UNKNOWN"; const entityName = node.split(".")[0]; - const entity = get(this.oldUnEvalTree, entityName); + const entity = get(this.oldUnEvalTree, entityName) as DataTreeEntity; const entityConfig = get(this.oldConfigTree, entityName); if (entity && isWidget(entity)) { entityType = entity.type; diff --git a/app/client/src/workers/common/DataTreeEvaluator/test.ts b/app/client/src/workers/common/DataTreeEvaluator/test.ts index dbd69786bd..f62265925c 100644 --- a/app/client/src/workers/common/DataTreeEvaluator/test.ts +++ b/app/client/src/workers/common/DataTreeEvaluator/test.ts @@ -16,6 +16,7 @@ import { replaceThisDotParams } from "./utils"; import { isDataField } from "./utils"; import widgets from "widgets"; import type { WidgetConfiguration } from "WidgetProvider/constants"; +import type { WidgetEntity } from "@appsmith/entities/DataTree/types"; const widgetConfigMap: Record< string, @@ -179,10 +180,11 @@ describe("DataTreeEvaluator", () => { event: "EDIT", }, ]; + const button2 = dataTreeEvaluator.oldUnEvalTree.Button2 as WidgetEntity; const newUnevalTree = { ...dataTreeEvaluator.oldUnEvalTree, Button2: { - ...dataTreeEvaluator.oldUnEvalTree.Button2, + ...button2, text: '{{""}}', }, }; @@ -210,10 +212,11 @@ describe("DataTreeEvaluator", () => { event: "EDIT", }, ]; + const button2 = dataTreeEvaluator.oldUnEvalTree.Button2 as WidgetEntity; const newUnevalTree = { ...dataTreeEvaluator.oldUnEvalTree, Button2: { - ...dataTreeEvaluator.oldUnEvalTree.Button2, + ...button2, text: "abc", }, };