【问题标题】:TypeScript consdering `undefined` as `any` - why?TypeScript 将 `undefined` 视为 `any` - 为什么?
【发布时间】:2022-08-19 02:22:37
【问题描述】:

一张价值一千字的截图,他们说:

为什么会这样?


我的 tsconfig.json:

{
  \"compileOnSave\": false,
  \"compilerOptions\": {
    \"rootDir\": \".\",
    \"baseUrl\": \".\",
    \"sourceMap\": true,
    \"declaration\": false,
    \"moduleResolution\": \"node\",
    \"emitDecoratorMetadata\": true,
    \"experimentalDecorators\": true,
    \"esModuleInterop\": true,
    \"importHelpers\": true,
    \"target\": \"ESNext\",
    \"module\": \"esnext\",
    \"lib\": [\"ESNext\", \"dom\", \"DOM.Iterable\"],
    \"skipLibCheck\": true,
    \"skipDefaultLibCheck\": true,
  },
  \"exclude\": [\"node_modules\", \"tmp\"]
}

    标签: typescript


    【解决方案1】:

    b 的类型可以是任何东西,它的值是未定义的。

    【讨论】:

      猜你喜欢
      • 2020-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-13
      • 1970-01-01
      • 2018-02-09
      • 2018-06-15
      相关资源
      最近更新 更多