【TypeScript 类报错】Property ‘name‘ has no initializer and is not definitely assigned in the constructor

TypeScript 语法文章: 【TypeScript】TS入门到实战(详解)_ts 使用 js-CSDN博客 【TypeScript】TS入门到实战(详解:高级类型)-CSDN博客 相关报错:Property 'name�

TypeScript 语法文章:

【TypeScript】TS入门到实战(详解)_ts 使用 js-CSDN博客

【TypeScript】TS入门到实战(详解:高级类型)-CSDN博客

  • 相关报错:Property 'name' has no initializer and is not definitely assigned in the constructor

  • 翻译一下:属性'name'没有初始化,也没有在构造函数中明确赋值
  • 报错原因:在Typescript 2.7 release版本出来后,设置了一个新的编译器选项strictPropertyInitialization。当本选项 strictPropertyInitialization:true 的时候,编译器会确保一个class类中所有的属性和方法都已经初始化,如果没有,那么在属性构建的过程中就会抛出错误。
  • 解决:

  &n

发布者:admin,转转请注明出处:http://www.yc00.com/web/1754371032a5153064.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信