0

I've created a new Nativescript Code Sharing Project following this page:

https://docs.nativescript.org/angular/code-sharing/creating-a-new-project

ng new -c=@nativescript/schematics TestProject --shared --style=scss

Then I've added the tns-platform-declarations following the steps in this page:

https://docs.nativescript.org/core-concepts/accessing-native-apis-with-javascript

But still when I try to use iOS specific classes (like NSString) it gives me an error on compilation:

error TS2552: Cannot find name 'NSString'.

In the old standard NS project it was working so it's possibly something related to the code sharing, what am I doing wrong?

This is a sample project: https://www.dropbox.com/s/66ve80jif3bf0qk/TestProject.zip?dl=0

demetrio812
  • 290
  • 3
  • 15
  • Sometimes you might have to restart VSCode for newly added declarations to be effective, did you try that? – Manoj Aug 19 '19 at 22:43
  • I have downloaded your code from dropbox and it is wring absolutely fine using vscode. – Narendra Aug 20 '19 at 06:16
  • Thanks to both, I've restarted multiple times, also deleted the hooks, node_modules and platofrms directories...will try again and will let you know. @Narendra what version of NS are you using? – demetrio812 Aug 24 '19 at 10:36
  • I've tried again with NS 6.0.3 but same result, what can I check to debug it? – demetrio812 Aug 25 '19 at 09:18

1 Answers1

0

I had the same problem as you described. VS Code recognized the typings as expected but the build failed.

I solved the issue by including reference.d.ts in tsconfig.tns.json.

"files": [
"./reference.d.ts",
"src/main.tns.ts"
]