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"
]

最新更新