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>; openKeyCursor(range?: IDBQuery, direction?: IDBCursorDirection | undefined): IDBRequest<IDBCursor | null>;
supports(method: string): boolean; supports(method: string): boolean;
keyPath: string | string[]; keyPath: string | string[];
get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | null>; get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | undefined>;
getKey(key: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey | undefined>; getKey(key: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey | undefined>;
} }
@ -78,7 +78,7 @@ export class QueryTarget<T> {
return this._target.supports(methodName); 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)); 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 { try {
LOG_REQUESTS && logRequest("get", [key], this._qt); LOG_REQUESTS && logRequest("get", [key], this._qt);
return this._qt.get(key); return this._qt.get(key);

View File

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

View File

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

View File

@ -35,7 +35,7 @@ export class GroupSessionDecryptionStore {
this._store = store; 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)); return this._store.get(encodeKey(roomId, sessionId, messageIndex));
} }

View File

@ -46,7 +46,7 @@ export class InboundGroupSessionStore {
return key === fetchedKey; 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)); 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)); return this._store.get(encodeKey(senderKey, sessionId));
} }

View File

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

View File

@ -46,7 +46,7 @@ export class RoomMemberStore {
this._roomMembersStore = roomMembersStore; 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)); return this._roomMembersStore.get(encodeKey(roomId, userId));
} }

View File

@ -36,7 +36,7 @@ export class RoomStateStore {
this._roomStateStore = idbStore; 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); const key = encodeKey(roomId, type, stateKey);
return this._roomStateStore.get(key); return this._roomStateStore.get(key);
} }

View File

@ -301,11 +301,11 @@ export class TimelineEventStore {
this._timelineStore.put(entry as TimelineEventStorageEntry); 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)); 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)); return this._timelineStore.index("byEventId").get(encodeEventIdKey(roomId, eventId));
} }

View File

@ -83,7 +83,7 @@ export class TimelineFragmentStore {
this._store.put(fragment); 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)); return this._store.get(encodeKey(roomId, fragmentId));
} }

View File

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