【发布时间】:2020-12-15 03:30:19
【问题描述】:
所以,我认为我的打字机 linter 短路了,因为我一生都无法弄清楚为什么这个 linting 错误不断出现。
Type 'IConnectionState' is not assignable to type '{ connected: false; type: "none"; }'
下面是我的代码,你可以清楚地看到,应该没有任何后果。
export interface IConnectionState {
connected: boolean;
type: 'none' | 'player' | 'host';
}
export const ConnectionState: RecoilState<IConnectionState> = atom({
key: 'connectionState',
default: {
connected: false,
type: 'none'
}
});
如果有帮助,我正在使用反冲。但看看后坐力类型,RecoilState 应该类型采用赋予其选项对象的default 值的子类型。
我很迷茫。
【问题讨论】:
标签: reactjs typescript recoiljs