typescript-export代码问题;别人的源码看不懂?请大佬解惑
这是个箭头函数吗?()还可以指定类别!(): ServerState => {
export const defaultState = (): ServerState => {
return {
klippy_retries: 0, // how many times have we attempted to reconnect to klippy.
info: {
failed_components: [],
klippy_connected: false, // indicates if klippy is disconnected vs shutdown.
klippy_state: '',
components: [],
registered_directories: [],
warnings: []
},
system_info: null,
config: {
authorization: {
enabled: true
},
server: {}
},
moonraker_stats: [],
throttled_state: {
bits: 0,
flags: []
},
cpu_temp: null
}
}
这两个名称分别代表什么内容?
interface ServerState
export interface ServerState {
klippy_retries: number;
info: ServerInfo;
system_info: SystemInfo | null;
config: ServerConfig;
moonraker_stats: ServerSystemStat[];
throttled_state: ServerThrottledState | null;
cpu_temp: number | null;
}
第一个指定函数返回值类型没有返回值要写void
第二个定义类型
页:
[1]