Issue
I'm new to typescript and I'm trying to see what the type should be for javascripts new Set([1, 2, 3])
, but can't find it anywhere.
for example:
const objNums: {[key: string]: number} = {one: 1, two: 2, three: 3};
const arrNums: Array<number> = [1, 2, 3];
const setNums /* : type??? */ = new Set([1, 2, 3]); // ????
// Example usage to explain why I need to assign a type to a variable and am asking what that type is:
function someFn(arg) {
console.log(arg);
}
someFn(setNums);
Solution
Thanks to @SharedRory.
const setNums: Set<number> = new Set([1, 2, 3]);
If he posts his answer, I'll give him the credit.
Answered By - Fiddle Freak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.