typescript - 打字稿类型 特定属性所需
问题描述
目标:
type Question = {
id: string;
answer?: string;
thirdProp?: number;
fourthProp?: number;
}
// usage Required<Question, 'answer' | 'thirdProp'> expect to equal
/*
type Question = {
id: string;
answer: string;
thirdProp: number;
fourthProp?: number;
}
*/
上面的例子应该很好解释。我想要Required
产生上述结果的类型。怎么能做到这一点?
解决方案
推荐阅读
- google-apps-script - 是否可以以编程方式创建一个 Google 表单,并将图像添加到多个简短回答类型的问题中?
- azure - Azure - 我是否应该续订应用注册,因为服务主体设置为一年后过期?
- saml - 在 SAML 响应中,我们应该签署 Response 还是 Assertion
- python - AttributeError:“DataGenerator”对象没有属性“类”
- javascript - Sinon 单元测试。如何对将调用异步函数的函数进行单元测试,然后调用将返回回调的函数?
- python - 第一次之后迭代文件更快
- html - 如何将 Javascript、CSS 和 HTML 内容转换为交互式 pdf 或 .h5p 页面
- amazon-web-services - 在获取 aws cognito 中身份调用的凭证中返回的访问密钥 ID 和秘密是什么?
- python - TypeError:将 ICS 放入 SymPy 时对象不可调用
- reactjs - 在 React 中为是/否对话添加键盘快捷键