Tyscript 使用Symbol时报错的原因

error TS2585: ‘Symbol’ only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.

原因:
Symbol是es6/es2015才出现的类型,需要将ts版本使用的js修改为es6
解决:
初始化ts,使之生成ts配置文件

tsc --init 

最后,将target改成es6即可
在这里插入图片描述


版权声明:本文为zsxy2019原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。