Skip to content

类型安全:Zustand store 状态用 any #26

@minorcell

Description

@minorcell

问题描述

src/store/index.ts 里 Zustand store 的状态定义用了 any

interface AppState {
  currentUser: any; // Add current user info
  // ...
  setCurrentUser: (user: any) => void;
}

这完全浪费了 TypeScript 的类型优势。

影响范围

  • 失去了类型提示
  • 容易传错数据
  • IDE 自动补全失效

建议方案

定义一个 User 类型:

interface User {
  id: string;
  email: string;
  name: string;
  role: 'admin' | 'teacher' | 'hr';
  avatar?: string;
  department?: string;
}

currentUser: User | null;
setCurrentUser: (user: User | null) => void;

本 Issue 由 Memo Code 生成。

@hjx2289206 @AlkaidSTART

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions