Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array.prototype[Symbol.unscopables] is not a function #34610

Closed
kazatsuyu opened this issue Oct 21, 2019 · 2 comments · Fixed by #36540 or #42566
Closed

Array.prototype[Symbol.unscopables] is not a function #34610

kazatsuyu opened this issue Oct 21, 2019 · 2 comments · Fixed by #36540 or #42566
Assignees
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript

Comments

@kazatsuyu
Copy link

TypeScript Version: 3.7.0-dev.20191018

Search Terms:

  • Array
  • @@unscopables

Code

const x = [][Symbol.unscopables];
console.log(x.copyWithin);

const y = [][Symbol.unscopables]();
console.log(y.copyWithin);

Expected behavior:
x.copyWithin occurs no error, and [][Symbol.unscopables]() occurs type error.

Actual behavior:
x.copyWithin occurs type error, and [][Symbol.unscopables]() occurs runtime exception.

Playground Link:
http://www.typescriptlang.org/play/?ts=Nightly&ssl=6&ssc=1&pln=1&pc=1#code/MYewdgzgLgBAHjAvDA2gXRQZQJ4FsBGIANgHQCukoADgIb5ECmEaA3ALABQokxDJRIAOYAKOCWrYA6gEsoAC2lgAlOw6du0GNiSoMOAsXKUQtekzTCV68BF78hw7OJNTZC5aqA

Related Issues:

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Oct 22, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.8.0 milestone Oct 22, 2019
@RyanCavanaugh RyanCavanaugh added the Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript label Oct 22, 2019
@NicholasLYang
Copy link
Contributor

NicholasLYang commented Oct 22, 2019

Is this because [Symbol.unscopables] is not a function but marked as one in the lib declaration file? According to MDN, object[Symbol.unscopables] should be an object. I removed the parens on this line and it appeared to fix the problem.

Building works correctly with the change but my IDE complains: TS2717: Subsequent property declarations must have the same type. I'm not really sure where the other property declarations of Symbol.unscopables are. Could I get a point in the right direction? Also should I change all the tests that use [Symbol.unscopables]() to [Symbol.unscopables]?

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Jan 31, 2021

@rbuckton This is still broken, so I’m fixing it in #42566.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript
Projects
None yet
5 participants