Reputation: 1297
I am new is ES6 and typescript. Trying to create function that accepts parameter as array and want to return its length as follows :
getSize = (friendsList : Friends[]) => friendsList.length ;
But it returns following error :
logger:17 TypeScript ';' expected. (TS1005)
logger:17 TypeScript Unexpected token. A constructor, method, accessor, or property was expected. (TS1068)
(index):20 Error: Error: TypeScript transpilation failed(…)
Upvotes: 3
Views: 87
Reputation: 329
I think may be you want to need is as below:
let getSize = (friendsList: Array<number>) => friendsList.length ;
console.log(getSize([1, 2, 3]));
So getSize is now a function and you can test it with above code.
I have tested above code.
Please test and let me know if it works for your scenario and any other help needed.
Upvotes: 2