Android-runtime: App won't compile - d.ts mismatch with tns-platform-declarations 4.2.0

Created on 7 Aug 2018  路  5Comments  路  Source: NativeScript/android-runtime

(Happens also with a plain new project tns create aaa --ng , details below) :

In our project we used this simple package.json file.

Notice :

"tns-platform-declarations": "~4.0.0",

Now let's see the d.ts files for android :

image

OK. let's run tsc ------>

image

All OK.

Additionally ( just saying it now to show that all ok for now in this code ) - we extend an Activity :

image

All OK - No errors.

Now let's update tns-platform-declarations to 4.2.0 :

So I'm changing to

 "tns-platform-declarations": "^4.2.0",

Now let's npm install tns-platform-declarations ( ack : installed OK)

Now the folder has changed ( obviously):

image

But now - Native android code ( in extending activity) doesn't get compiled:

image

You can also see this error with tsc :

image

More , if I remove this method , it yells on other things :

image

So basically the new dt.s are causing compilation errors.

If I revert back to "tns-platform-declarations": "~4.0.0", - the error disappear.

NOTE

It happens also with PLAIN new project tns create aaa --ng , ( just add the additional activity file)

image

bug

All 5 comments

Hey @RoyiNamir which declaration file are you using? Can you post your reference.d.ts content

Hey @NickIliev

/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

You can create a new project (tns create aaa --ng ), and add tns-platform-declarations ( 4.2.0!) and add this file ^ (references.d.ts)

And see that it happens also there ( when you add this activity file)

Here is the activity file : https://gist.github.com/RoyiNamir/e84420a9bb67636f2e08388a611af658
(same as in here)

Here is a demo plain new project: https://ufile.io/mzon5

Hi @RoyiNamir, You will need to change all the methods to be public, because that's how we generate the typings now, we don't have protected methods anymore. About the error for the onRequestPermissionsResult you need to change the type to Array<string>, string need to be lowercase and it should work.

@vtrifonov Hi.
Thanks for reply.
I've already solved it in my code like you said :-)
But I think ( Just suggesting of course) that this should be reported as
"a breaking change" pretty quickly so that people won't think that that there's a problem with NS 4.2 ( when they upgrade)

Becuase if you now tns create aaa --ng and npm install tns-platform-declerations , it will install the 4.2 declarations - which causes current(!) code to break.

If it's not a bug - then it should be written in the upgrade instructions that "from now on... you should s and not S , and public/protected switches).

Thanks for the suggestion, we have added those breaking changes to the NativeScript changelog

Was this page helpful?
0 / 5 - 0 ratings

Related issues

x4080 picture x4080  路  5Comments

zahid-dapperapps picture zahid-dapperapps  路  3Comments

georgeedwards picture georgeedwards  路  3Comments

triniwiz picture triniwiz  路  4Comments

Natalia-Hristova picture Natalia-Hristova  路  3Comments