nativescript - Nativescript 6代码共享项目和tns-platform-declarations:编译时出错
问题描述
我在此页面之后创建了一个新的 Nativescript 代码共享项目:
https://docs.nativescript.org/angular/code-sharing/creating-a-new-project
ng new -c=@nativescript/schematics TestProject --shared --style=scss
然后我tns-platform-declarations
在此页面中添加了以下步骤:
https://docs.nativescript.org/core-concepts/accessing-native-apis-with-javascript
但是当我尝试使用 iOS 特定的类(如 NSString)时,它仍然给我一个编译错误:
error TS2552: Cannot find name 'NSString'.
在旧的标准 NS 项目中它正在工作,所以它可能与代码共享有关,我做错了什么?
这是一个示例项目:https ://www.dropbox.com/s/66ve80jif3bf0qk/TestProject.zip?dl=0
解决方案
我遇到了和你描述的一样的问题。VS Code 按预期识别类型,但构建失败。
我通过在tsconfig.tns.json中包含reference.d.ts解决了这个问题。
"files": [
"./reference.d.ts",
"src/main.tns.ts"
]
推荐阅读
- reactjs - 如何使用多个不同的值传入 onChange 以传入
- postgresql - 对 postgres 存储过程的类型转换调用不匹配
- pdf - 无法使用 emacs pdf-tools 打开 PDF 文件
- javascript - Javascript - 用 Woocommerce 订单表数据填充 PDF 上的 HTML 表
- java - 春季启动休息:NullPointerException错误
- r - 在R中找到无穷大的极限
- apache-spark - spark sql中提取的解析器异常
- xquery - 从 BaseX 数据库中读取非 xml 文件
- r - 来自 R 中 PLSR 的 pls 包错误:组件数量无效
- r - 使用 likert 绘图包绘图,包括组,并按最高百分比对结果进行排序