From 22df062bbb4723f8f028fdb89827f3e8d3e10d23 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:05:02 +0200 Subject: [PATCH] fix observable typescript errors --- src/domain/SessionPickerViewModel.js | 2 +- src/matrix/Session.js | 2 +- src/matrix/room/timeline/Timeline.js | 2 +- src/observable/{index.js => index.ts} | 9 +++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) rename src/observable/{index.js => index.ts} (78%) diff --git a/src/domain/SessionPickerViewModel.js b/src/domain/SessionPickerViewModel.js index e486c64f..f65fd2e6 100644 --- a/src/domain/SessionPickerViewModel.js +++ b/src/domain/SessionPickerViewModel.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {SortedArray} from "../observable/index.js"; +import {SortedArray} from "../observable/index"; import {ViewModel} from "./ViewModel"; import {avatarInitials, getIdentifierColorNumber} from "./avatar"; diff --git a/src/matrix/Session.js b/src/matrix/Session.js index bd361434..9d63d335 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -21,7 +21,7 @@ import {RoomStatus} from "./room/common"; import {RoomBeingCreated} from "./room/RoomBeingCreated"; import {Invite} from "./room/Invite.js"; import {Pusher} from "./push/Pusher"; -import { ObservableMap } from "../observable/index.js"; +import { ObservableMap } from "../observable/index"; import {User} from "./User.js"; import {DeviceMessageHandler} from "./DeviceMessageHandler.js"; import {Account as E2EEAccount} from "./e2ee/Account.js"; diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index 3332a5b0..de17fce2 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {SortedArray, AsyncMappedList, ConcatList, ObservableArray} from "../../../observable/index.js"; +import {SortedArray, AsyncMappedList, ConcatList, ObservableArray} from "../../../observable/index"; import {Disposables} from "../../../utils/Disposables"; import {Direction} from "./Direction"; import {TimelineReader} from "./persistence/TimelineReader.js"; diff --git a/src/observable/index.js b/src/observable/index.ts similarity index 78% rename from src/observable/index.js rename to src/observable/index.ts index 6057174b..040ec761 100644 --- a/src/observable/index.js +++ b/src/observable/index.ts @@ -46,3 +46,12 @@ Object.assign(BaseObservableMap.prototype, { return new JoinedMap([this].concat(otherMaps)); } }); + +declare module "./map/BaseObservableMap" { + interface BaseObservableMap { + sortValues(comparator: (a: V, b: V) => number): SortedMapList; + mapValues(mapper: (V, emitSpontaneousUpdate: (params: any) => void) => M, updater: (mappedValue: M, params: any, value: V) => void): MappedMap; + filterValues(filter: (V, K) => boolean): FilteredMap; + join(...otherMaps: BaseObservableMap[]): JoinedMap; + } +}