解决TS8010: Type annotations can only be used in TypeScript files. |
您所在的位置:网站首页 › flow文件是什么 › 解决TS8010: Type annotations can only be used in TypeScript files. |
刚开始搞ts的时候遇到这个报错: TS8010: Type annotations can only be used in TypeScript files. SyntaxError: Unexpected token ':' 出问题的代码: let arr:number[] = [1, 2, 3];看报错是不认识冒号,这种类型用法只能出现在ts文件里 随即修改文件后缀为.ts,此时用node运行也没有用了,用ts-node跑,再试试就OK了! 总结下来原因有2: 1,如果是js文件,则需要改为ts文件,并用ts-node运行; 2,如果是ts文件,却用node去运行了。 希望帮助到你! |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |