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

2 posts, 0 answers
  1. Nasser
    Nasser avatar
    1 posts
    Member since:
    Feb 2016

    Posted 15 Feb 2016 Link to this post

    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? 


  2. Hristo Deshev
    Hristo Deshev avatar
    1 posts

    Posted 17 Feb 2016 Link to this post

    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.

    Hristo Deshev

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

Back to Top