NativeScript Permissions - Cannot find name 'android'?


#1

I’m using the Spartadigital NativeScript Permissions plugin

I’ve also did :

tns plugin add @spartadigital/nativescript-permissions

And inside the ts file :

import {Permissions} from '@spartadigital/nativescript-permissions';

However when I run tns run android : I get :

node_modules/@spartadigital/nativescript-permissions/permissions.android.d.ts(2,37): error TS2304: Cannot find name 'android'.

node_modules/@spartadigital/nativescript-permissions/permissions.android.d.ts(3,34): error TS2304: Cannot find name 'android'.
node_modules/@spartadigital/nativescript-permissions/permissions.ios.d.ts(24,47): error TS2552: Cannot find name 'NSObject'. Did you mean 'Object'?
node_modules/@spartadigital/nativescript-permissions/permissions.ios.d.ts(24,67): error TS2304: Cannot find name 'CLLocationManagerDelegate'.
node_modules/@spartadigital/nativescript-permissions/permissions.ios.d.ts(26,20): error TS2304: Cannot find name 'CLLocationManagerDelegate'.

Looking at the file , I see that it doesn’t know android :

image

Nor other IOS objects :

I already have tns-platform-declarations :

image

Question:

Why doesn’t it recognize those keywords and how can I fix it ?

package.json

ts.config


#2

ANswered by Brad here : https://stackoverflow.com/a/47755859/859154

I copied those declarations to the root reference.d.ts and it works.


#3

This is a bit odd though. The TS compiler shouldn’t have any business with how the definitions are composed within your node_modules. Even though this seems like the solution, could you share the contents of your tsconfig.json?


#4

@jogboms ts.config is in the question ( at the bottom).

Also discussed here :

it’s becuase of the root : reference.d.ts


#5

Well if thats the case then. I just read the github convo. As Nick rightly said, all plugins should only have compiled js files. Very well then. :+1:


#6

@jogboms
It wasn’t on a typical TS file. but d.ts file. who had incorrect path for other d.ts location. ( just like core-modes had). :slight_smile: