This is a migrated thread and some comments may be shown as answers.

Generic type 'Promise<T, R>' requires 2 type argument

1 Answer 2157 Views
AppBuilder in-browser client
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nasser
Top achievements
Rank 1
Nasser asked on 15 Feb 2016, 09:06 AM

I'm working on a NavtiveScript project (Typescript-based). On my local environment(using tns cli), it compiled and work fine.  

However, when I sync it back (git pull/push) to Telrike platform (IDE),  TS compiler erroring out some semantic errors.

SemanticError: Generic type 'Promise<T, R>' requires 2 type argument(s)

 

I thought something went wrong with the syncing process. So I created a new NativeScript app using HelloWord template with typescript enabled via in-browser client.

 I created a simple class(TestES6) as below. Again, I got same result that same errors during compilation.

class TestES6 {
 
    public bar(p: Promise) {} // SemanticError: Generic type 'Promise<T, R>' requires 2 type argument(s)
 
    public foo<T>(p: Promise<T>){} // // SemanticError: Generic type 'Promise<T, R>' requires 2 type argument(s)
 
    public foobar<T,R>(p: Promise<T,R>){} // compiled! 
 
}
 

By looking into 'es6-promise.d' which is included in the tns-core-modules. Promise is been defined as Promise<R> not as Promise<T,R>. 

And according TS #6248 , I think Telerik TS compiler getting additional type definition of  Promise<T>.

 

Can you please confirm this, or I'm doing something wrong in here? 

 

1 Answer, 1 is accepted

Sort by
0
Hristo Deshev
Telerik team
answered on 17 Feb 2016, 09:48 AM
Hi, Nasser,

Yes, that's a clash between the Promise definition in the NS modules and the ES6 typings. I usually see it in Angular projects that drag a reference to es6-shim and its typings.

The good news is that we've fixed that problem. In the 1.6.0 release we are shipping a version of the typings that do not include our own ES6 definitions, allowing users to plug their own typing. That will be enabled by building against tns-core-modules.es6.d.ts instead of the usual tns-core-modules.d.ts file.


Regards,
Hristo Deshev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
AppBuilder in-browser client
Asked by
Nasser
Top achievements
Rank 1
Answers by
Hristo Deshev
Telerik team
Share this question
or