typescript常见问题集锦

1.在ts中,碰到Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Object'.   No index signature with a parameter of type 'string' was found on type 'Object'.

这种问题测出现时说:元素隐式具有“any”类型,因为“string”类型的表达式不能用于索引类型“Object”。在类型“Object”上找不到“string”类型参数的索引签名。

要想解决这类问题,需要在tsconfig.json文件中配置:"suppressImplicitAnyIndexErrors": true 就可以解决此类问题。

2.在vue中,使用此命令 vue add @vue/typescript,出现如下错误得时候:

 在对应得文件夹中删除vue.ps1就ok了。

原文地址:https://www.cnblogs.com/lxz123/p/13564628.html