2

TypeScript seems to not correctly support array literals spread operator.

Array.from example worked const uniq1 = (list: Iterable<any>): Array<any> => Array.from(new Set<any>(list))

Array spread example broken const uniq2 = (list: Iterable<any>): Array<any> => [...new Set<any>(list)]

The second example return the following error: Type 'Set' is not an array type.

1
  • What's Set? I think it's your own type which is not iterable and that's why it's not working. Please include more code. Commented Oct 7, 2016 at 8:10

2 Answers 2

2

TypeScript doesn't support spread operator now, but it will change in future:

https://github.com/Microsoft/TypeScript/wiki/Roadmap#21

Sign up to request clarification or add additional context in comments.

Comments

0

This is a missing feature. Spreads ... aren't fully implemented yet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.