在版本更新后,Typescript Promise不通用?

时间:2017-11-16 09:23:54

标签: typescript generics

在我再次解构我的整个应用程序之前,我有点困惑并且可以使用一些帮助。

我将Angular 4 App更新为Angular 5.并将Typescript版本设置为2.4.2 现在我的IDEA编辑在这样的行上说“类型承诺不是通用的”,例如:

Private Sub updateChart1()

   Dim month
   Dim year
   Dim stringToFind
   Dim newRange
   Dim foundString
   Dim newRange1
   Dim newrange2

   'Assign a value to the month and the year
   month = VBA.DateTime.month(Date)
   year = VBA.DateTime.year(Date)

   'Make the search for string equal to the month + year variables
   stringToFind = month & "/" & year

   'Declare a range where you will look for the month and year
   Set newRange = Worksheets("Sheet1").Range("C16:Z16")

   'Search for the month and year
   Set foundString = newRange.Find(stringToFind)

   'Once the correct date has been found, resize the range to be the new data source
   Set newRange1 = foundString.Offset(0, -12)

   Set newrange2 = newRange1.Resize(2, 12)


   'Update the chart with the new data source
   Worksheets("Sheet2").ChartObjects("Chart1").Chart.SetSourceData Source:=newrange2

End Sub

我使用es5并编译(除了过时的fullcalendar - 另一个问题)。

有人知道它来自哪里和/或如何摆脱它?

提前致谢! 格里

1 个答案:

答案 0 :(得分:0)

使用promise可能取决于您的目标JavaScript版本。

您应该可以通过定位更高版本来解决问题:

{
    "compilerOptions": {
      "target": "ESNext", // <-- Later ES version
      "module": "amd",
      "strict": true,
      "noImplicitAny": true,
      "allowJs": true,
      "sourceMap": true,
      "allowSyntheticDefaultImports": false,
      "moduleResolution": "node",
      "noUnusedLocals": true,
      "noUnusedParameters": false,
      "preserveConstEnums": false,
      "removeComments": false
    },
    "exclude": [
      "node_modules",
      "test",
      ".git"
    ]
}

或者通过配置您的库包含。例如:

{
    "compilerOptions": {
      "target": "ES5", // <-- ES5
      "module": "amd",
      "strict": true,
      "noImplicitAny": true,
      "allowJs": true,
      "sourceMap": true,
      "allowSyntheticDefaultImports": false,
      "moduleResolution": "node",
      "noUnusedLocals": true,
      "noUnusedParameters": false,
      "preserveConstEnums": false,
      "removeComments": false,
      "lib": [ // <-- lib config
        "es5",
        "es6",
        "dom",
        "es2015.core",
        "es2015.collection",
        "es2015.generator",
        "es2015.iterable",
        "es2015.promise",
        "es2015.proxy",
        "es2015.reflect",
        "es2015.symbol",
        "es2015.symbol.wellknown",
        "esnext.asynciterable"
      ]
    },
    "exclude": [
      "node_modules",
      "test",
      ".git"
    ]
  }