小编omo*_*ade的帖子

无法将对象字面量分配给`...`,因为对象字面量[1]中缺少属性`...`,但存在于`...`中

我是新手,目前正在从事严格流程的项目。我有一个传递给类的类型别名。片段可以在这里找到

// @flow strict

export type CustomType = {
  a: string,
  b: boolean,
  c: boolean,
  d: boolean,
  e: boolean
};
let d = true;
let b = true;
let customType:CustomType = {
        d,
        b,
        c: true,
 }

class Custom{
  constructor(customType = {}) {}
}

let custom = new Custom(customType);
Run Code Online (Sandbox Code Playgroud)

传递对象时,并非所有属性customType都存在。最好的解决方法是什么?

flowtype

5
推荐指数
1
解决办法
4430
查看次数

标签 统计

flowtype ×1