美文网首页Angular
Argument of type '' is not assig

Argument of type '' is not assig

作者: survivorsfyh | 来源:发表于2021-01-04 16:27 被阅读0次

简而言之,言而简之,记录一下日常开发中遇到的问题;
在创建初始化数组后向数组中 push 数据的时候抛出了如下异常:
Argument of type '{}' is not assignable to parameter of type 'never'.
ts 语法上的一些规范,规范强个人感觉还是很不错的,更加规规矩矩,初始化的时候完善一下定义类型就行了,具体 code 如下;

// 问题的写法
const dataSource = [];

// 完善后的写法
const dataSource: any[] = [];

注:js 写惯了经常会 var,ts 的时候用 const 即可。


以上便是此次分享的全部内容,希望能对大家有所帮助!

相关文章

网友评论

    本文标题:Argument of type '' is not assig

    本文链接:https://www.haomeiwen.com/subject/bduvoktx.html