【发布时间】:2020-11-18 11:06:34
【问题描述】:
我正在尝试创建如下的io-ts接口
my-interface.ts
export interface myInterface {
[key:string]?: string | undefined | null
}
我想把它变成 io-ts 等价物。最终目标是将其与另一个现有的 io-ts 接口结合起来
my-other-interface.ts
export const MyOtherInterfaceV = t.interface({
requiredProp1: ValidString// custom type, checks string is populated
requiredProp2: ValidString
// All other fields marked as required
})
export type MyOtherInterface = t.TypeOf<typeof MyOtherInterfaceV>;
我的想法是我需要一个类型来表示有效负载,该有效负载将包含一些我们需要且必须有效的字段,以及一些我们不知道且可以是可选的字段。我们希望将这些组合起来以供稍后在处理中使用,最终存储在 dynamodb 中
【问题讨论】:
-
嗨@jbailie1991 我的回答对你有用吗?
标签: typescript types fp-ts