mobx icon indicating copy to clipboard operation
mobx copied to clipboard

TypeScript 5.5 compatibility for `ObservableSet`

Open SimenB opened this issue 1 year ago • 1 comments

Intended outcome:

MobX's ObservableSet should implement all Set methods.

https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#support-for-new-ecmascript-set-methods

Actual outcome:

It doesn't, leading to

node_modules/mobx/dist/types/observableset.d.ts:25:22 - error TS2420: Class 'ObservableSet<T>' incorrectly implements interface 'Set<T>'.
  Type 'ObservableSet<T>' is missing the following properties from type 'Set<T>': union, intersection, difference, symmetricDifference, and 3 more.

25 export declare class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillChange>, IListenable {

How to reproduce the issue:

https://www.typescriptlang.org/play/?target=99&ts=5.5.2#code/JYWwDg9gTgLgBAbzgeQEYGcCmUBuBDVAG0wGVN4BfOAMyghDgHIQJUAPRgbgChuBjCADt08FuzIwAXHAkAeAK6CA1oIgB3QQD44AXjiDMalBmz4ipcgAoAlDyA

Changing TS versions to 5.4.5 resolves the type error.

Playground doesn't have skipLibCheck: false, otherwise the implements within the MobX type would fail rather than the satisfies.

Versions

[email protected]

SimenB avatar Jun 24 '24 07:06 SimenB

Should be fixed by https://github.com/mobxjs/mobx/pull/3853

kubk avatar Jun 25 '24 05:06 kubk

Duplicate of #3850

SimenB avatar Jul 01 '24 10:07 SimenB