change store.get return type when no value is found to undefined

IDBRequest.result is undefined according to the official TS type decls.
This commit is contained in:
Bruno Windels 2022-01-25 18:43:44 +01:00
parent 993a86ddb2
commit 5d87d8bde3
13 changed files with 17 additions and 17 deletions

View file

@ -37,7 +37,7 @@ interface QueryTargetInterface<T> {
openKeyCursor(range?: IDBQuery, direction?: IDBCursorDirection | undefined): IDBRequest<IDBCursor | null>;
supports(method: string): boolean;
keyPath: string | string[];
get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | null>;
get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | undefined>;
getKey(key: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey | undefined>;
}
@ -78,7 +78,7 @@ export class QueryTarget<T> {
return this._target.supports(methodName);
}
get(key: IDBValidKey | IDBKeyRange): Promise<T | null> {
get(key: IDBValidKey | IDBKeyRange): Promise<T | undefined> {
return reqAsPromise(this._target.get(key));
}

View file

@ -91,7 +91,7 @@ export class QueryTargetWrapper<T> {
}
}
get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | null> {
get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | undefined> {
try {
LOG_REQUESTS && logRequest("get", [key], this._qt);
return this._qt.get(key);

View file

@ -28,7 +28,7 @@ export class AccountDataStore {
this._store = store;
}
async get(type: string): Promise<AccountDataEntry | null> {
async get(type: string): Promise<AccountDataEntry | undefined> {
return await this._store.get(type);
}

View file

@ -17,7 +17,7 @@ limitations under the License.
import {MAX_UNICODE, MIN_UNICODE} from "./common";
import {Store} from "../Store";
interface DeviceIdentity {
export interface DeviceIdentity {
userId: string;
deviceId: string;
ed25519Key: string;
@ -65,7 +65,7 @@ export class DeviceIdentityStore {
return deviceIds;
}
get(userId: string, deviceId: string): Promise<DeviceIdentity | null> {
get(userId: string, deviceId: string): Promise<DeviceIdentity | undefined> {
return this._store.get(encodeKey(userId, deviceId));
}
@ -74,7 +74,7 @@ export class DeviceIdentityStore {
this._store.put(deviceIdentity);
}
getByCurve25519Key(curve25519Key: string): Promise<DeviceIdentity | null> {
getByCurve25519Key(curve25519Key: string): Promise<DeviceIdentity | undefined> {
return this._store.index("byCurve25519Key").get(curve25519Key);
}

View file

@ -35,7 +35,7 @@ export class GroupSessionDecryptionStore {
this._store = store;
}
get(roomId: string, sessionId: string, messageIndex: number): Promise<GroupSessionDecryption | null> {
get(roomId: string, sessionId: string, messageIndex: number): Promise<GroupSessionDecryption | undefined> {
return this._store.get(encodeKey(roomId, sessionId, messageIndex));
}

View file

@ -46,7 +46,7 @@ export class InboundGroupSessionStore {
return key === fetchedKey;
}
get(roomId: string, senderKey: string, sessionId: string): Promise<InboundGroupSessionEntry | null> {
get(roomId: string, senderKey: string, sessionId: string): Promise<InboundGroupSessionEntry | undefined> {
return this._store.get(encodeKey(roomId, senderKey, sessionId));
}

View file

@ -62,7 +62,7 @@ export class OlmSessionStore {
});
}
get(senderKey: string, sessionId: string): Promise<OlmSession | null> {
get(senderKey: string, sessionId: string): Promise<OlmSession | undefined> {
return this._store.get(encodeKey(senderKey, sessionId));
}

View file

@ -32,7 +32,7 @@ export class OutboundGroupSessionStore {
this._store.delete(roomId);
}
get(roomId: string): Promise<OutboundSession | null> {
get(roomId: string): Promise<OutboundSession | undefined> {
return this._store.get(roomId);
}

View file

@ -46,7 +46,7 @@ export class RoomMemberStore {
this._roomMembersStore = roomMembersStore;
}
get(roomId: string, userId: string): Promise<MemberStorageEntry | null> {
get(roomId: string, userId: string): Promise<MemberStorageEntry | undefined> {
return this._roomMembersStore.get(encodeKey(roomId, userId));
}

View file

@ -36,7 +36,7 @@ export class RoomStateStore {
this._roomStateStore = idbStore;
}
get(roomId: string, type: string, stateKey: string): Promise<RoomStateEntry | null> {
get(roomId: string, type: string, stateKey: string): Promise<RoomStateEntry | undefined> {
const key = encodeKey(roomId, type, stateKey);
return this._roomStateStore.get(key);
}

View file

@ -301,11 +301,11 @@ export class TimelineEventStore {
this._timelineStore.put(entry as TimelineEventStorageEntry);
}
get(roomId: string, eventKey: EventKey): Promise<TimelineEventEntry | null> {
get(roomId: string, eventKey: EventKey): Promise<TimelineEventEntry | undefined> {
return this._timelineStore.get(encodeKey(roomId, eventKey.fragmentId, eventKey.eventIndex));
}
getByEventId(roomId: string, eventId: string): Promise<TimelineEventEntry | null> {
getByEventId(roomId: string, eventId: string): Promise<TimelineEventEntry | undefined> {
return this._timelineStore.index("byEventId").get(encodeEventIdKey(roomId, eventId));
}

View file

@ -83,7 +83,7 @@ export class TimelineFragmentStore {
this._store.put(fragment);
}
get(roomId: string, fragmentId: number): Promise<FragmentEntry | null> {
get(roomId: string, fragmentId: number): Promise<FragmentEntry | undefined> {
return this._store.get(encodeKey(roomId, fragmentId));
}

View file

@ -28,7 +28,7 @@ export class UserIdentityStore {
this._store = store;
}
get(userId: string): Promise<UserIdentity | null> {
get(userId: string): Promise<UserIdentity | undefined> {
return this._store.get(userId);
}