Skip to content

Commit

Permalink
refactor: any 타입 전체 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
sikkzz committed Feb 15, 2025
1 parent 2f590c1 commit 4d147e4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/components/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Home = () => {
onClick={() => {
send({ type: AppBridgeMessageType.OPEN_GALLERY, payload: "" });

send({ type: AppBridgeMessageType.RECEIVE_SCAN_RESULT, payload: scanData });
send({ type: AppBridgeMessageType.RECEIVE_SCAN_RESULT, payload: { result: "" } });
}}
/>
<IconButton
Expand All @@ -55,7 +55,7 @@ const Home = () => {
onClick={() => {
send({ type: AppBridgeMessageType.OPEN_CAMERA, payload: "" });

send({ type: AppBridgeMessageType.RECEIVE_SCAN_RESULT, payload: scanData });
send({ type: AppBridgeMessageType.RECEIVE_SCAN_RESULT, payload: { result: "" } });
}}
/>
</div>
Expand Down
5 changes: 1 addition & 4 deletions src/components/ReceiptEdit/ReceiptEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ const ReceiptEdit = () => {

const { setOcrText } = useCreateReviewStore();

const [formData, setFormData] = useState<{ [key: string]: string }[]>([
{ test: "abc" },
{ test2: "aadsasf" },
]);
const [formData, setFormData] = useState<{ key: string; value: string }[]>([]);
const [focusState, setFocusState] = useState<{ [key: string]: boolean }>({});

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export interface CopyMessage {

export interface ReceiveScanResultMessage {
type: AppBridgeMessageType.RECEIVE_SCAN_RESULT;
// payload: Array<{ [key: string]: string }>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
payload: any;
payload: {
result: string;
};
}

export interface ReceiveGeneratedReviewMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export function AppBridgeProvider({ children }: AppBridgeProviderProps) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
receiveScanResult: (jsonData: any) => {
try {
// alert("Scan Result: " + jsonData);
setScanData(JSON.parse(jsonData));
} catch (error) {
console.error("Invalid JSON data for scan result:", error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const iosHandlers = {
}) => window.webkit?.messageHandlers.createReview.postMessage(message.payload),
[AppBridgeMessageType.COPY]: (message: { payload: { review: string } }) =>
window.webkit?.messageHandlers.copy.postMessage(message.payload),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[AppBridgeMessageType.RECEIVE_SCAN_RESULT]: (message: { payload: { result: any } }) =>
[AppBridgeMessageType.RECEIVE_SCAN_RESULT]: (message: { payload: { result: string } }) =>
window.response?.receiveScanResult(message.payload.result),
[AppBridgeMessageType.RECEIVE_GENERATED_REVIEW]: (message: { payload: { result: string } }) =>
window.response?.receiveGeneratedReview(message.payload.result),
Expand All @@ -29,8 +28,7 @@ const androidHandlers = {
}) => window.AndroidBridge?.createReview(JSON.stringify(message.payload)),
[AppBridgeMessageType.COPY]: (message: { payload: { review: string } }) =>
window.AndroidBridge?.copy(JSON.stringify(message.payload)),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[AppBridgeMessageType.RECEIVE_SCAN_RESULT]: (message: { payload: { result: any } }) =>
[AppBridgeMessageType.RECEIVE_SCAN_RESULT]: (message: { payload: { result: string } }) =>
window.response?.receiveScanResult(message.payload.result),
[AppBridgeMessageType.RECEIVE_GENERATED_REVIEW]: (message: { payload: { result: string } }) =>
window.response?.receiveGeneratedReview(message.payload.result),
Expand Down
13 changes: 5 additions & 8 deletions src/store/useScanDataStore.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { create } from "zustand";

interface ScanDataStoreProps {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
scanData: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setScanData: (scanData: any[]) => void;
scanData: ScanResultPayload;
setScanData: (scanData: ScanResultPayload) => void;
resetScanData: () => void;
}

export const useScanDataStore = create<ScanDataStoreProps>((set) => ({
scanData: [],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setScanData: (scanData: any[]) => set({ scanData }),
resetScanData: () => set({ scanData: [] }),
scanData: { parsed: [] },
setScanData: (scanData: ScanResultPayload) => set({ scanData }),
resetScanData: () => set({ scanData: { parsed: [] } }),
}));
4 changes: 4 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ declare global {
interface CopyMessagePayload {
review: string;
}

interface ScanResultPayload {
parsed: Array<{ key: string; value: string }>;
}
interface Window {
response?: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 4d147e4

Please sign in to comment.