- This topic has 3 replies, 2 voices, and was last updated 7 years, 4 months ago by support-swapna.
-
AuthorPosts
-
gorandParticipantHellow!
I need to use a variable type definition on an incoming variable type.
See the code below – it was here to define a function call with a number key, but instead, a function with a string key and an unknown data type is defined (see the attached images)interface IObj { i:number; } // type data interface IEach { each<TT>(p_obj:{[key:string]:TT}, p_fn:(v:TT, k:string) => void); // key string, data IObj each<TT>(p_obj:{[key:number]:TT}, p_fn:(v:TT, k:number) => void); // key number, data IObj } export function test4() { var l_array:{[key:number]:IObj[]}; // declare variable var l_each:IEach; // emulate interface instance fo call l_each.each(l_array, function(v, k) { v.sort(function(v1, v2) { return v1.i -v2.i; }); }); // ERROR }
- This topic was modified 7 years, 4 months ago by gorand.
Attachments:
You must be logged in to view attached files.
gorandParticipantIf you swap the function declaration and put the key first: number – then everything works correctly.
interface IObj { i:number; } interface IEach { each<TT>(p_obj:{[key:number]:TT}, p_fn:(v:TT, k:number) => void); // key number to move first each<TT>(p_obj:{[key:string]:TT}, p_fn:(v:TT, k:string) => void); // key string to move second } export function test4() { var l_array:{[key:number]:IObj[]}; var l_each:IEach; // emulate interface instance l_each.each(l_array, function(v, k) { v.sort(function(v1, v2) { return v1.i -v2.i; }); }); }
Why is this happening? How to fix it?
- This reply was modified 7 years, 4 months ago by gorand.
Attachments:
You must be logged in to view attached files.
support-swapnaModeratorgorand,
Sorry that you are seeing this issue. Thank you for the details and the screenshots. We are investigating the problem and we will get back to you soon.
Apologies for inconvenience caused.
–Swapna
MyEclipse Support
support-swapnaModeratorGorand,
The problem reported by you is a limitation in TypeScript. I am afraid we cannot fix it at our end.
I suggest you cross post to TypeScript or development related forums like stackoverflow.com for better suggestions from the developer community.Sorry that we couldn’t assist further.
–Swapna
MyEclipse Support -
AuthorPosts