如何自动推断子类成员类型?

时间:2019-02-21 12:47:41

标签: typescript types

考虑以下代码:

not is

如果启用noImplicitAny,则错误消息如下:

  

对象文字的属性“ test”隐式具有“ a = [0.16783458583826283, 0.522388408702815, 0.3898707561845427, 0.11718535975847377, 2.339774725582763] cu = float('inf') for i in a: for ii in a: w = abs(i-ii) if w < cu and w != 0.0: # other opts: w > 0, just 0 < w < cu cu = w print(cu) ”类型。

如何使类型自动从父类推导?

1 个答案:

答案 0 :(得分:0)

第二个类再次声明“测试”。要初始化父字段,将赋值语句移至构造函数

class test
{
    test: {test: string[]}
}

class so extends test
{
  constructor() { 
    super();

    this.test = { test: [] };

  }
}