首页 > 其他分享 >TypeScript:Type 'boolean' is not assignable to type 'never'.

TypeScript:Type 'boolean' is not assignable to type 'never'.

时间:2022-12-06 10:00:37浏览次数:71  
标签:assignable TypeScript type never boolean Type

问题原因

当我们声明一个空数组而不显示键入它并尝试向其中添加元素时,会发生该错误。
image

image

解决方案

声明数组类型即可
image

参考链接

https://bobbyhadz.com/blog/typescript-argument-type-not-assignable-parameter-type-never

标签:assignable,TypeScript,type,never,boolean,Type
From: https://www.cnblogs.com/leoych/p/16954374.html

相关文章

  • React中的BUG记录——Error: Element type is invalid: expected a string (for built
    问题描述语法各个方面没有问题,报以下错误:Error:Elementtypeisinvalid:expectedastring(forbuilt-incomponents)oraclass/function(forcompositecomponents......
  • TypeScript 之 Interface
    Interface描述:用来描述对象的形状,能够被继承常用语法(CommonSyntax)1.描述普通对象interfaceJsonResponse{version:number;outOfStock?:boolean;rea......
  • .NET7 Preview4:重构的返回值TypedResults
    为了更好的测试,更好的性能,Preview4带了一个新的请求返回值类型,这个新的类型中封装了所有的Http请求返回状态函数,还包括了返回成功后的几种数据类型,下面列举了几个常用的......
  • .NET7 Preview4:重构的返回值TypedResults
    为了更好的测试,更好的性能,Preview4带了一个新的请求返回值类型,这个新的类型中封装了所有的Http请求返回状态函数,还包括了返回成功后的几种数据类型,下面列举了几个常用......
  • .NET7 Preview4:重构的返回值TypedResults
    为了更好的测试,更好的性能,Preview4带了一个新的请求返回值类型,这个新的类型中封装了所有的Http请求返回状态函数,还包括了返回成功后的几种数据类型,下面列举了几个常用......
  • 解决[Vue warn]: Property or method “preCarriagePriceType“ is not defined on th
    #vue警告[Vuewarn]:Propertyormethod“name”isnotdefinedontheinstancebutreferencedduringrender.Makesurethatthispropertyisreactive,eitheri......
  • [Typescript] 127. Hard - Assign
    Youhaveatargetobjectandasourcearrayofobjects.Youneedtocopypropertyfromsourcetotarget,ifithasthesamepropertyasthesource,youshould......
  • 我要涨知识——TypeScript 常见面试题(二)
    又是一个年底来了,好大一批人可能又准备跑路了,最近回家待产话不多说,赶紧开干,给自己整了一个前端面试小助手——微信小程序内搜索“WEB学习学习加油站”,整理了前端经典高频......
  • TS中interface和type的区别
    1.概念1.接口(interface)接口主要用于类型检查,他只是一个结构契约,定义了具有相似的名称和类型的对象结构。除此之外,接口还可以定义方法和事件。2.类型别名(TypeAlias)不同......
  • [Typescript] 126. Hard - Two Sum
    Givenanarrayofintegers nums andaninteger target,returntrueiftwonumberssuchthattheyaddupto target./*_____________YourCodeHere________......