鱼C论坛

 找回密码
 立即注册
查看: 1123|回复: 1

typescript-export代码问题;别人的源码看不懂?请大佬解惑

[复制链接]
发表于 2022-6-3 16:25:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
这是个箭头函数吗?()还可以指定类别!
(): ServerState => {
  1. export const defaultState = (): ServerState => {
  2.   return {
  3.     klippy_retries: 0, // how many times have we attempted to reconnect to klippy.
  4.     info: {
  5.       failed_components: [],
  6.       klippy_connected: false, // indicates if klippy is disconnected vs shutdown.
  7.       klippy_state: '',
  8.       components: [],
  9.       registered_directories: [],
  10.       warnings: []
  11.     },
  12.     system_info: null,
  13.     config: {
  14.       authorization: {
  15.         enabled: true
  16.       },
  17.       server: {}
  18.     },
  19.     moonraker_stats: [],
  20.     throttled_state: {
  21.       bits: 0,
  22.       flags: []
  23.     },
  24.     cpu_temp: null
  25.   }
  26. }
复制代码


这两个名称分别代表什么内容?
interface ServerState

  1. export interface ServerState {
  2.   klippy_retries: number;
  3.   info: ServerInfo;
  4.   system_info: SystemInfo | null;
  5.   config: ServerConfig;
  6.   moonraker_stats: ServerSystemStat[];
  7.   throttled_state: ServerThrottledState | null;
  8.   cpu_temp: number | null;
  9. }
复制代码

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-6-5 11:08:46 | 显示全部楼层
第一个指定函数返回值类型  没有返回值要写void

第二个定义类型
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-27 21:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表