2

Following the docs for "Generation and Iteration for ES5", I added the following polyfill:

(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator");

This causes my browser to throw an error:

Uncaught TypeError: Cannot assign to read only property ‘asyncIterator’ of function ‘function Symbol() { [native code] }’

1 Answer 1

2

Since the property is readonly, only assign it when it doesn't exist:

if (typeof (Symbol as any).asyncIterator  === 'undefined') {
 (Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol('asyncIterator');
}
Sign up to request clarification or add additional context in comments.

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.