TypeScript 错误“property does not exist on value of type”
2017-01-05 19:45
846 查看
在用TypeScript写angular2或者ionic2项目时,导入原来JavaScript代码,有时出现“property does not exist on value of type”问题
即该对象找不到此属性,原因是ts是静态语言,类型是需要定义的,未定义就有可能找不到。
最简单的解决方式是:加 as any
eg:y.x报错,则改为
即该对象找不到此属性,原因是ts是静态语言,类型是需要定义的,未定义就有可能找不到。
最简单的解决方式是:加 as any
eg:y.x报错,则改为
(y as any).x
相关文章推荐
- [ Vue-ts-错误 ] Property '$router|$store' does not exist on type Vue
- 解决编译错误:Property 'value' not found on object of type '_strong id'
- android studio编程时出现的错误:Cannot get property 'XXXX' on extra properties extension as it does not exist
- Property 'subscribe' does not exist on type '() => Observable<any>'
- Ionic iframe - [ts] Property 'contentWindow' does not exist on type 'HTMLElement'.
- Property 'value' not found on type java.lang.String的错误原因
- angular2 Property 'map' does not exist on type 'Observable<Response>'.
- 错误:A SPI class of type org.apache.lucene.*** with name 'Whitespace' does not exist.
- Xcode 报错: value of type InerfaceController does not conform to HKWorkoutSessionDelegate in assignmen
- 异常:Property 'name' not found on type java.lang.String,attribute items does not accept any
- 遇到错误javax.el.PropertyNotFoundException: Property 'start' not found on type java.lang.String
- Property OldCreateOrder does not exist 错误解决!
- Cannot execute as the database principal because the principal "guest" does not exist, this type of principal cannot be impersonated, or you do not have permission.
- Eclipse下JUnit报错“The input type of the launch configuration does not exist ”
- studio编译出错Cannot get property 'versionCode' on extra properties extension as it does not exist
- android switch(String)错误:Cannot switch on a value of type String for source level below 1.7
- 'ddlCities' has a SelectedValue which is invalid because it does not exist in the list of items
- 关于JSP中使用EL表达式遇到的错误Property 'productId' not found on type com.imooc.hello.Product
- JUnit: The input type of the launch configuration does not exist
- 解决The type or namespace name \'XXXX\' does not exist in the namespace \'XXXXXXXXX\' 的错误