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

Property 'difference' does not exist on type 'Set' #60012

Closed
ghost opened this issue Sep 20, 2024 · 3 comments
Closed

Property 'difference' does not exist on type 'Set' #60012

ghost opened this issue Sep 20, 2024 · 3 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@ghost
Copy link

ghost commented Sep 20, 2024

🔎 Search Terms

is:issue set difference does not exist

🕗 Version & Regression Information

I tested this on the Nightly TypeScript version, 5.7, 5.6, etc.

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about FAQ (For Issue Filers)

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.7.0-dev.20240919#code/PTAEAsBdIBwZwFwgCYFMBuqA2B7GqAnAOgFscAvASyywEMicCBzYVAOwFoBVAZWGRwBjOMADqqAEbAAUrXS0eggpRiRgAJVQAzQu0GpgAcVwTaWAPoB5CQCtUgyCJ6o1ySlp0E9qACQAGAChBHDY4SFAcZGQ4UABeUDZUAHdQZ0gACgBtAEYAGlAAZnyAVnyAdnyATgBdAEoAbiCQsNA4AEcAV1ovGPjElLSsvNAAFiq6xuDQnCxUIlwmdMjoojcPXTZ9dPauntqG0BBUl3SC2tAAb0KS8tAAXyA

💻 Code

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference$0
const odds = new Set([1, 3, 5, 7, 9]);
const squares = new Set([1, 4, 9]);
console.log(odds.difference(squares)); // Set(3) { 3, 5, 7 }

🙁 Actual behavior

Property 'difference' does not exist on type 'Set<number>'.ts(2339)

TypeScript does not recognize the property.

🙂 Expected behavior

I expected TypeScript to recognize the property, since:

  1. MDN confirms it is widely available
  2. Add types for stage 3 "set methods" proposal #57228 and add types for set methods proposal #57230 seem to have accepted and merged this back in May.

Why is the compiler still showing that it isn't recognized?

Additional information about the issue

No response

@ghost ghost closed this as completed Sep 20, 2024
@itsramiel
Copy link

@occassionally why did you close this? How did you resolve the issue?

@ghost ghost reopened this Sep 20, 2024
@ghost
Copy link
Author

ghost commented Sep 20, 2024

@itsramiel I closed it because I tested it and the functions aren't available on Node 20.16.0, and possibly not in JavaScript itself either (still in draft phase, I didn't test specifically), so I figured this was why TypeScript didn't recognize it. I just wrote my own implementations.

I re-opened it though, so we can get the maintainers' feedback.

@jcalz
Copy link
Contributor

jcalz commented Sep 20, 2024

Make sure your --target is for a version of JavaScript that supports this. In this case, esnext: playground link

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Sep 20, 2024
@ghost ghost closed this as completed Sep 22, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants