When using the plugin with NativeScript 3.1., tns-core-modules 3.1.0 and TypeScript 2.2.1 the below error appears when we try to import the plugin as a module.
Reproducible on both iOS and Android. Test application demonstrating the issue can be found here (to reproduce just clone the app and execute tns run command)
e.g.
import * as https from "nativescript-https";
results to
Executing before-prepare hook from /Users/Jey/Desktop/suresh/fp/MyBlue2/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/Jey/Desktop/suresh/fp/MyBlue2/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.2.2
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(45,18): error TS2314: Generic type 'Iterator<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(500,19): error TS2314: Generic type 'Set<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(502,28): error TS2314: Generic type 'Map<K, V>' requires 2 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(503,24): error TS2314: Generic type 'Map<K, V>' requires 2 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(530,33): error TS2314: Generic type 'Set<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(597,37): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(605,35): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(605,69): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(757,32): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(764,33): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(764,67): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(931,34): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(938,33): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(938,67): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1042,36): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1123,25): error TS2314: Generic type 'Iterator<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1346,52): error TS2314: Generic type 'WeakReference<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1425,56): error TS2314: Generic type 'Set<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1621,35): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1632,35): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1632,69): error TS2314: Generic type 'Enum<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(1994,32): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2042,134): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2042,159): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2061,32): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2061,86): error TS2314: Generic type 'Class<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2759,39): error TS2694: Namespace 'java.nio' has no exported member 'file'.
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2759,80): error TS2694: Namespace 'java.nio' has no exported member 'file'.
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2762,41): error TS2694: Namespace 'java.nio' has no exported member 'file'.
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2762,82): error TS2694: Namespace 'java.nio' has no exported member 'file'.
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2767,31): error TS2314: Generic type 'AbstractList<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2768,28): error TS2314: Generic type 'Collection<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2770,25): error TS2314: Generic type 'Collection<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2776,22): error TS2314: Generic type 'Iterator<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2777,30): error TS2694: Namespace 'java.util' has no exported member 'stream'.
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2778,35): error TS2694: Namespace 'java.util' has no exported member 'Spliterator'.
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2785,40): error TS2314: Generic type 'ListIterator<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2787,41): error TS2314: Generic type 'Collection<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2788,23): error TS2314: Generic type 'Comparator<T>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2789,28): error TS2314: Generic type 'Collection<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2793,26): error TS2314: Generic type 'ListIterator<E>' requires 1 type argument(s).
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2794,38): error TS2694: Namespace 'java.util' has no exported member 'stream'.
node_modules/nativescript-https/com.squareup.okhttp3.d.ts(2796,30): error TS2314: Generic type 'Collection<E>' requires 1 type argument(s).
node_modules/nativescript-https/index.d.ts(1,15): error TS2306: File '/Users/Jey/Desktop/suresh/fp/MyBlue2/node_modules/nativescript-https/AFNetworking.d.ts' is not a module.
node_modules/nativescript-https/index.d.ts(2,15): error TS2306: File '/Users/Jey/Desktop/suresh/fp/MyBlue2/node_modules/nativescript-https/com.squareup.okhttp3.d.ts' is not a module.
TypeScript compiler failed with exit code 1
As a temporary solution I have wrapped both declaration files (AFNetworking.d.ts and com.squareup.okhttp3.d.ts) in a module export statements
e.g.
export module AFNetworking {
.. file content follows here
}
The above solution seems to resolve the issue - please advice for the best approach.
When using the plugin with NativeScript 3.1., tns-core-modules 3.1.0 and TypeScript 2.2.1 the below error appears when we try to import the plugin as a module.
Reproducible on both iOS and Android. Test application demonstrating the issue can be found here (to reproduce just clone the app and execute
tns run
command)e.g.
results to
As a temporary solution I have wrapped both declaration files (
AFNetworking.d.ts
andcom.squareup.okhttp3.d.ts
) in a module export statementse.g.
The above solution seems to resolve the issue - please advice for the best approach.