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,20 @@
import { UsePresetOptions, TPreset, SetOption, SetExample } from 'librechat-data-provider';
import { TPreset } from 'librechat-data-provider';
import type { TSetOptionsPayload, TSetExample, TSetOption } from '~/common';
import { useRecoilState, useRecoilValue } from 'recoil';
import { cleanupPreset } from '~/utils';
import store from '~/store';
const usePresetOptions: UsePresetOptions = (_preset) => {
type TUsePresetOptions = (preset?: TPreset | boolean | null) => TSetOptionsPayload | boolean;
const usePresetOptions: TUsePresetOptions = (_preset) => {
const [preset, setPreset] = useRecoilState(store.preset);
const endpointsConfig = useRecoilValue(store.endpointsConfig);
if (!_preset) {
return false;
}
const getConversation: () => TPreset | null = () => preset;
const setOption: SetOption = (param) => (newValue) => {
const setOption: TSetOption = (param) => (newValue) => {
const update = {};
update[param] = newValue;
setPreset((prevState) =>
@ -24,7 +28,7 @@ const usePresetOptions: UsePresetOptions = (_preset) => {
);
};
const setExample: SetExample = (i, type, newValue = null) => {
const setExample: TSetExample = (i, type, newValue = null) => {
const update = {};
const current = preset?.examples?.slice() || [];
const currentExample = { ...current[i] } || {};