What is “not assignable to parameter of type never” error in typescript?

前端 未结 10 2201
無奈伤痛
無奈伤痛 2020-12-04 15:08

Code is:

const foo = (foo: string) => {
  const result = []
  result.push(foo)
}

I get the following TS error:

[t

10条回答
  •  暖寄归人
    2020-12-04 15:27

    Remove "strictNullChecks": true from "compilerOptions" or set it to false in the tsconfig.json file of your Ng app. These errors will go away like anything and your app would compile successfully.

    Disclaimer: This is just a workaround. This error appears only when the null checks are not handled properly which in any case is not a good way to get things done.

提交回复
热议问题