Typings for NSArray and NSDictionary


It seems like the typings in tns-platform-declarations for NSArray and NSDictionary are wrong, at least according to the documentation on calling native classes at https://docs.nativescript.org/core-concepts/accessing-native-apis-with-javascript

The documentation, in the Arrays section, says you can create an NSArray as follows:
var nsArray = NSArray.arrayWithArray([‘Four’, ‘Five’, ‘Two’, ‘Seven’]);

However, the typing for arrayWithArray in tns-platform-declarations is:
static arrayWithArray(array: NSArray): NSArray;

So you get an error when writing the call above as written. It seems like the typing instead should be:
static arrayWithArray(array: ObjectType[]): NSArray;

Similarly for NSDictionary, where the documentation says you can write:
var dict = new NSDictionary([".example.com"], [NSHTTPCookieDomain]);

but the typing is:
constructor(o: { objects: NSArray; forKeys: NSArray; });
which should probably be:
constructor(objects: ObjectType[], forKeys: KeyType[]);

(similar changes would need to be made throughout)

Unfortunately, it’s somewhat complex making the change and trying it out. I’ll work on that, but in the meantime, I want to confirm the typings.

P.S. I’m using “tns-platform-declarations”: “~4.0.0”


Can you post this as an issue in GitHub? It sounds like a framework bug maybe.


Done (posted as issue #6001)