From 998788001947557efc9c3247ced5eb407ee61b19 Mon Sep 17 00:00:00 2001 From: dilesoft Date: Thu, 12 Dec 2024 22:05:04 +0300 Subject: [PATCH] revert typescript --- src-editor/src/App.tsx | 48 +++++++++---------- src-editor/src/Components/BlocklyEditor.tsx | 2 +- .../components/Blocks/ActionSayText.tsx | 7 +-- .../components/Blocks/TriggerSchedule.tsx | 4 +- .../components/ContextWrapper/index.tsx | 26 +++++----- .../components/GenericBlock/index.tsx | 4 +- .../Components/RulesEditor/helpers/utils.tsx | 2 +- src-editor/src/Editor.tsx | 21 ++++---- src-editor/src/OpenAi/OpenAiDialog.tsx | 1 - src-editor/src/OpenAi/OpenAiPrompt.tsx | 4 +- src-editor/src/bootstrap.tsx | 2 - src-editor/tsconfig.json | 1 + 12 files changed, 57 insertions(+), 65 deletions(-) diff --git a/src-editor/src/App.tsx b/src-editor/src/App.tsx index 4abfc420..247ff968 100644 --- a/src-editor/src/App.tsx +++ b/src-editor/src/App.tsx @@ -25,17 +25,17 @@ import { ContextWrapper } from './Components/RulesEditor/components/ContextWrapp import { Box } from '@mui/material'; import type { GenericAppProps, GenericAppState } from '@iobroker/adapter-react-v5/build/types'; -// import enLang from './i18n/en.json'; -// import deLang from './i18n/de.json'; -// import esLang from './i18n/es.json'; -// import frLang from './i18n/fr.json'; -// import itLang from './i18n/it.json'; -// import nlLang from './i18n/nl.json'; -// import plLang from './i18n/pl.json'; -// import ptLang from './i18n/pt.json'; -// import ruLang from './i18n/ru.json'; -// import ukLang from './i18n/uk.json'; -// import zhCnLang from './i18n/zh-cn.json'; +import enLang from './i18n/en.json'; +import deLang from './i18n/de.json'; +import esLang from './i18n/es.json'; +import frLang from './i18n/fr.json'; +import itLang from './i18n/it.json'; +import nlLang from './i18n/nl.json'; +import plLang from './i18n/pl.json'; +import ptLang from './i18n/pt.json'; +import ruLang from './i18n/ru.json'; +import ukLang from './i18n/uk.json'; +import zhCnLang from './i18n/zh-cn.json'; import type { ScriptType } from '@/types'; const styles: Record = { @@ -173,17 +173,17 @@ class App extends GenericApp { // @ts-expect-error fix later Connection: AdminConnection, translations: { - // en: enLang, - // de: deLang, - // es: esLang, - // fr: frLang, - // it: itLang, - // nl: nlLang, - // pl: plLang, - // pt: ptLang, - // ru: ruLang, - // uk: ukLang, - // 'zh-cn': zhCnLang, + en: enLang, + de: deLang, + es: esLang, + fr: frLang, + it: itLang, + nl: nlLang, + pl: plLang, + pt: ptLang, + ru: ruLang, + uk: ukLang, + 'zh-cn': zhCnLang, }, bottomButtons: false, socket: { @@ -549,7 +549,7 @@ class App extends GenericApp { } nId = newId + nId.substring(id.length); obj._id = nId; - obj.common = obj.common || {} as ioBroker.StateCommon; + obj.common = obj.common || {}; obj.common.expert = true; await this.socket.setObject(nId, obj); await this.renameGroup(id, newId, newName, _list); @@ -687,7 +687,7 @@ class App extends GenericApp { if (oldId === newId && _obj?.common && newCommon.name === _obj.common.name) { if (!newCommon.engineType || newCommon.engineType !== _obj.common.engineType) { if (newCommon.engineType !== undefined) { - obj.common.engineType = newCommon.engineType || 'JavaScript/js'; + obj.common.engineType = newCommon.engineType || 'Javascript/js'; } } obj.type = 'script'; diff --git a/src-editor/src/Components/BlocklyEditor.tsx b/src-editor/src/Components/BlocklyEditor.tsx index bc155c73..40d7ffa2 100644 --- a/src-editor/src/Components/BlocklyEditor.tsx +++ b/src-editor/src/Components/BlocklyEditor.tsx @@ -182,7 +182,7 @@ class BlocklyEditor extends React.Component null; + parseXml = () => null; } return parseXml(text); } diff --git a/src-editor/src/Components/RulesEditor/components/Blocks/ActionSayText.tsx b/src-editor/src/Components/RulesEditor/components/Blocks/ActionSayText.tsx index ec1c1a45..604e4f28 100644 --- a/src-editor/src/Components/RulesEditor/components/Blocks/ActionSayText.tsx +++ b/src-editor/src/Components/RulesEditor/components/Blocks/ActionSayText.tsx @@ -3,12 +3,7 @@ import { GenericBlock, type GenericBlockProps } from '../GenericBlock'; import type { RuleBlockConfigActionSayText, RuleBlockDescription, RuleContext } from '@/Components/RulesEditor/types'; // copied from https://github.com/ioBroker/ioBroker.sayit/blob/master/admin/blockly.js#L37 -const sayitEngines: Record - = { +const sayitEngines = { en: { name: 'Google - English', engine: 'google', params: [] }, de: { name: 'Google - Deutsch', engine: 'google', params: [] }, ru: { name: 'Google - Русский', engine: 'google', params: [] }, diff --git a/src-editor/src/Components/RulesEditor/components/Blocks/TriggerSchedule.tsx b/src-editor/src/Components/RulesEditor/components/Blocks/TriggerSchedule.tsx index 2358e0ca..44378366 100644 --- a/src-editor/src/Components/RulesEditor/components/Blocks/TriggerSchedule.tsx +++ b/src-editor/src/Components/RulesEditor/components/Blocks/TriggerSchedule.tsx @@ -401,7 +401,7 @@ class TriggerScheduleBlock extends GenericBlock { wizardText = description || ''; const wizardObj: ScheduleConfig = JSON.parse(schedule) as ScheduleConfig; - wizardObj.valid = wizardObj.valid || {} as any; + wizardObj.valid = wizardObj.valid || {}; wizardObj.valid.from = wizardObj.valid.from || Schedule.now2string(); wizard = JSON.stringify(wizardObj); }} @@ -436,7 +436,7 @@ class TriggerScheduleBlock extends GenericBlock, item: RuleBlockDescription) { super(props); - item = item || {} as any; + item = item || {}; const settings: Settings = props.settings || ({ @@ -502,7 +502,7 @@ export abstract class GenericBlock< return this.props.socket .getObject(newId) .then(o => this.findIcon(o)) - .catch((): any => null); + .catch(() => null); } return Promise.resolve(null); } diff --git a/src-editor/src/Components/RulesEditor/helpers/utils.tsx b/src-editor/src/Components/RulesEditor/helpers/utils.tsx index 0c04774f..8c1c14cc 100644 --- a/src-editor/src/Components/RulesEditor/helpers/utils.tsx +++ b/src-editor/src/Components/RulesEditor/helpers/utils.tsx @@ -6,7 +6,7 @@ export function getName(obj: undefined | ioBroker.StringOrTranslated | null): st if (obj && typeof obj === 'object') { return obj[lang] || obj.en; } - return obj as string || ''; + return obj || ''; } export function renderValue(val: any): string { diff --git a/src-editor/src/Editor.tsx b/src-editor/src/Editor.tsx index 3e58eff4..be041369 100644 --- a/src-editor/src/Editor.tsx +++ b/src-editor/src/Editor.tsx @@ -375,7 +375,7 @@ class Editor extends React.Component { } this.selectId.callback = cb as (selected: string | string[] | undefined) => void; this.selectId.initValue = initValue; - this.selectId.type = type as any; + this.selectId.type = type; this.setState({ showSelectId: true }); }, cronDialog: (initValue, cb) => { @@ -827,11 +827,11 @@ class Editor extends React.Component { const common = this.scripts[selected] || (this.props.objects[selected] && this.props.objects[selected].common); this.setState({ selected, - rules: (common as any).engineType === 'Rules', - blockly: (common as any).engineType === 'Blockly', + rules: common.engineType === 'Rules', + blockly: common.engineType === 'Blockly', showCompiledCode: false, - verboseEnabled: (common as any).verbose, - debugEnabled: (common as any).debug, + verboseEnabled: common.verbose, + debugEnabled: common.debug, }); this.props.onSelectedChange && this.props.onSelectedChange(selected, this.state.editing); } @@ -883,10 +883,10 @@ class Editor extends React.Component { newState.selected && (this.scripts[newState.selected] || (this.props.objects[newState.selected] && this.props.objects[newState.selected].common)); - newState.blockly = common ? (common as any).engineType === 'Blockly' : false; - newState.rules = common ? (common as any).engineType === 'Rules' : false; - newState.verboseEnabled = common ? (common as any).verbose : false; - newState.debugEnabled = common ? (common as any).debug : false; + newState.blockly = common ? common.engineType === 'Blockly' : false; + newState.rules = common ? common.engineType === 'Rules' : false; + newState.verboseEnabled = common ? common.verbose : false; + newState.debugEnabled = common ? common.debug : false; newState.showCompiledCode = false; } @@ -1993,11 +1993,10 @@ class Editor extends React.Component { runningInstances={this.state.runningInstances} adapterName={this.props.adapterName} socket={this.props.socket} - // @ts-expect-error fix later theme={this.props.theme} themeName={this.props.themeName} themeType={this.props.themeType} - // @#ts-expect-error fix later + // @ts-expect-error fix later src={this.props.debugInstance ? this.props.debugInstance.adapter : this.state.selected} debugInstance={this.props.debugInstance} /> diff --git a/src-editor/src/OpenAi/OpenAiDialog.tsx b/src-editor/src/OpenAi/OpenAiDialog.tsx index 42708c10..82f88d44 100644 --- a/src-editor/src/OpenAi/OpenAiDialog.tsx +++ b/src-editor/src/OpenAi/OpenAiDialog.tsx @@ -152,7 +152,6 @@ Do not import any libraries as all functions are already imported.`, ], }); const message = chatCompletionPhase1.choices[0].message; - // @ts-expect-error const m = message.content?.match(/```(javascript|js|typescript)\n?(.*)```(.*)/ms); let code; if (!m) { diff --git a/src-editor/src/OpenAi/OpenAiPrompt.tsx b/src-editor/src/OpenAi/OpenAiPrompt.tsx index 131e5f2d..4cfa35b1 100644 --- a/src-editor/src/OpenAi/OpenAiPrompt.tsx +++ b/src-editor/src/OpenAi/OpenAiPrompt.tsx @@ -1,7 +1,7 @@ import ChannelDetector, { type DetectOptions, Types } from '@iobroker/type-detector'; import { type AdminConnection, I18n } from '@iobroker/adapter-react-v5'; import type { PatternControl } from '@iobroker/type-detector'; -// @ts-expect-error +//@ts-expect-error const docs = import(`./docs.md?raw`); interface DeviceState { @@ -66,7 +66,7 @@ function getText(text: ioBroker.StringOrTranslated, lang: ioBroker.Languages): s if (text && typeof text === 'object') { return text[lang] || text.en; } - return text as string || ''; + return text || ''; } async function detectDevices(socket: AdminConnection): Promise { diff --git a/src-editor/src/bootstrap.tsx b/src-editor/src/bootstrap.tsx index 19718709..c79d16ab 100644 --- a/src-editor/src/bootstrap.tsx +++ b/src-editor/src/bootstrap.tsx @@ -3,9 +3,7 @@ import { createRoot } from 'react-dom/client'; import './index.css'; import App from './App'; -// @ts-expect-error import * as serviceWorker from './serviceWorker'; -// @ts-expect-error import pgk from '../package.json'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; diff --git a/src-editor/tsconfig.json b/src-editor/tsconfig.json index 9661bd97..010772ac 100644 --- a/src-editor/tsconfig.json +++ b/src-editor/tsconfig.json @@ -1,6 +1,7 @@ // Specialized tsconfig for the admin directory, // includes DOM typings and configures the admin build { + "extends": "../tsconfig.json", "compilerOptions": { "baseUrl": "./", "allowSyntheticDefaultImports": true,