代码之家  ›  专栏  ›  技术社区  ›  jprism

WebStorm:参数类型不能分配给参数类型ObjectConstructor

  •  1
  • jprism  · 技术社区  · 7 年前

    当我在TypeScript中使用以下构造函数时,我得到的错误参数类型是不能分配给参数类型ObjectConstructor的。但CLI没有显示错误。代码在我看来没问题( syntax ).这是一个错误吗?

    export class Store{
      oid: string;
      storeNumber: string;
      address: string;
    
      public constructor(init?: Partial<Store>) {
        Object.assign(this, init);
      }
    }
    
    0 回复  |  直到 7 年前
        1
  •  4
  •   tao    7 年前

    这已被记录为 WebStorm bug (谢谢, @lena ).

    在发布修复程序之前,可以通过在包含假阳性的行上方放置以下注释来禁止检查:

    // noinspection TypeScriptValidateTypes
    
    推荐文章