diff --git a/lib/core.js b/lib/core.js index 1d6ce0c869f..38aac50d48f 100644 --- a/lib/core.js +++ b/lib/core.js @@ -278,7 +278,7 @@ declare class Symbol { * by Array.prototype.concat. */ static isConcatSpreadable: $SymboIsConcatSpreadable; - static iterator: string; // polyfill '@@iterator' + static iterator: '@@iterator'; // polyfill '@@iterator' /** * Returns a key from the global symbol registry matching the given Symbol if found. * Otherwise, returns a undefined. diff --git a/tests/symbol/iterator.js b/tests/symbol/iterator.js new file mode 100644 index 00000000000..03a8ee49423 --- /dev/null +++ b/tests/symbol/iterator.js @@ -0,0 +1,6 @@ +declare var foo: { + @@iterator: Iterator, +}; + +(foo[Symbol.iterator]: Iterator); // OK +(foo[Symbol.iterator]: boolean); // Error diff --git a/tests/symbol/symbol.exp b/tests/symbol/symbol.exp index c5bf86e192c..99a71bc7e6c 100644 --- a/tests/symbol/symbol.exp +++ b/tests/symbol/symbol.exp @@ -1,3 +1,21 @@ +Error -------------------------------------------------------------------------------------------------- iterator.js:6:2 + +Cannot cast `foo[Symbol.iterator]` to boolean because `$Iterator` [1] is incompatible with boolean [2]. +[incompatible-cast] + + iterator.js:6:2 + 6| (foo[Symbol.iterator]: boolean); // Error + ^^^^^^^^^^^^^^^^^^^^ + +References: + iterator.js:2:15 + 2| @@iterator: Iterator, + ^^^^^^^^^^^^^^^^ [1] + iterator.js:6:24 + 6| (foo[Symbol.iterator]: boolean); // Error + ^^^^^^^ [2] + + Error --------------------------------------------------------------------------------------------------- symbol.js:8:17 Cannot call `Symbol` because no more than 1 argument is expected by function type [1]. [extra-arg] @@ -137,4 +155,4 @@ References: -Found 8 errors +Found 9 errors