refactor(client): Refactors recent typescript changes for best practices (#763)

* create common types in client

* remove unnecessary rules from eslint config

* cleanup types

* put back eslintrc rules
This commit is contained in:
Dan Orlando 2023-08-05 13:45:26 -07:00 committed by GitHub
parent 5828200197
commit 96d29f7390
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 233 additions and 245 deletions

View file

@ -1,16 +1,12 @@
import {
UseSetOptions,
TConversation,
SetOption,
SetExample,
TPlugin,
tConversationSchema,
} from 'librechat-data-provider';
import { TConversation, TPreset, TPlugin, tConversationSchema } from 'librechat-data-provider';
import type { TSetExample, TSetOption, TSetOptionsPayload } from '~/common';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import usePresetOptions from './usePresetOptions';
import store from '~/store';
const useSetOptions: UseSetOptions = (preset = false) => {
type TUseSetOptions = (preset?: TPreset | boolean | null) => TSetOptionsPayload;
const useSetOptions: TUseSetOptions = (preset = false) => {
const setShowPluginStoreDialog = useSetRecoilState(store.showPluginStoreDialog);
const [conversation, setConversation] = useRecoilState(store.conversation);
const availableTools = useRecoilValue(store.availableTools);
@ -21,7 +17,7 @@ const useSetOptions: UseSetOptions = (preset = false) => {
return result;
}
const setOption: SetOption = (param) => (newValue) => {
const setOption: TSetOption = (param) => (newValue) => {
const update = {};
update[param] = newValue;
setConversation((prevState) =>
@ -32,7 +28,7 @@ const useSetOptions: UseSetOptions = (preset = false) => {
);
};
const setExample: SetExample = (i, type, newValue = null) => {
const setExample: TSetExample = (i, type, newValue = null) => {
const update = {};
const current = conversation?.examples?.slice() || [];
const currentExample = { ...current[i] } || {};
@ -92,7 +88,7 @@ const useSetOptions: UseSetOptions = (preset = false) => {
return conversation.tools.find((el) => el.pluginKey === value) ? true : false;
}
const setAgentOption: SetOption = (param) => (newValue) => {
const setAgentOption: TSetOption = (param) => (newValue) => {
const editableConvo = JSON.stringify(conversation);
const convo = JSON.parse(editableConvo);
const { agentOptions } = convo;