Skip to content

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

Closed
@ghost

Description

🔎 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions