facebook

Why can not TypeScript automatically detect a generic type in function?

  1. CodeMix & Angular IDE
  2.  > 
  3. Webclipse 1.x Help
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #515354 Reply

    gorand
    Participant

    Sample code:

    
    type TestFn<T> = (v:T, k:string) => void;
    function runTest<T, TT extends {[key:string]:T}>(p_obj:TT, pp:TestFn<T>) { }
    var Map:{[key:string]:string[]} = {};
    runTest(Map, function(v, k) {});
    

    This code parameter v is {} but should be string[] like java does
    see attached images

    • This topic was modified 7 years, 9 months ago by gorand. Reason: add image
    Attachments:
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)
Reply To: Why can not TypeScript automatically detect a generic type in function?

You must be logged in to post in the forum log in