typescript - 从对象的联合中省略一个对象
问题描述
我使用的库将类型定义为:
export declare type LogInResult = {
type: 'cancel';
} | {
type: 'success';
accessToken: string | null;
idToken: string | null;
refreshToken: string | null;
user: GoogleUser;
};
SuccessLoginResult
我想通过省略对象来创建类型{ type: 'cancel' }
,这可能吗?
我试过的一些伪代码不起作用:
type SuccessLoginResult = Omit<LogInResult, { type: 'cancel' }>
解决方案
推荐阅读
- c++ - 使用 brew 安装 boost 时缺少 boost_signals 库
- c++ - 如何在 tableWidget 的单元格中访问小部件内的值?
- android - 即使在使用了有效加载大位图指南之后,如何避免 OutOfMemoryError
- c# - 从具有不同表中值字段的网络表单中插入值
- typescript - 初始化时具有空属性的 TypeScript 类
- bash - 如果比较从文件中读取的数字时语句测试失败
- python - 测试用户模型是否有密码的正确方法
- r - ggplot2 - 减少点之间的距离(缩小效果)
- r - 如何直接从 R Studio 的 R 控制台使用文字编辑器(.docx)打开预先保存的文本文件(.txt)?
- amazon-iam - ECS集群无法使用KMS密钥解密“你无权访问”