1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Fix up some more type defs

This commit is contained in:
Michael Telatynski
2021-06-17 14:49:27 +01:00
parent 7c61b9cf7e
commit 608b0e7b93

View File

@@ -87,7 +87,7 @@ export interface IEvent {
txn_id?: string; txn_id?: string;
state_key?: string; state_key?: string;
membership?: string; membership?: string;
unsigned?: IUnsigned; unsigned: IUnsigned;
redacts?: string; redacts?: string;
// v1 legacy fields // v1 legacy fields
@@ -324,11 +324,11 @@ export class MatrixEvent extends EventEmitter {
* *
* @return {Object} The event content JSON, or an empty object. * @return {Object} The event content JSON, or an empty object.
*/ */
public getOriginalContent(): IContent { public getOriginalContent<T = IContent>(): T {
if (this._localRedactionEvent) { if (this._localRedactionEvent) {
return {}; return {} as T;
} }
return this.clearEvent.content || this.event.content || {}; return (this.clearEvent.content || this.event.content || {}) as T;
} }
/** /**
@@ -338,9 +338,9 @@ export class MatrixEvent extends EventEmitter {
* *
* @return {Object} The event content JSON, or an empty object. * @return {Object} The event content JSON, or an empty object.
*/ */
public getContent(): IContent { public getContent<T = IContent>(): T {
if (this._localRedactionEvent) { if (this._localRedactionEvent) {
return {}; return {} as T;
} else if (this._replacingEvent) { } else if (this._replacingEvent) {
return this._replacingEvent.getContent()["m.new_content"] || {}; return this._replacingEvent.getContent()["m.new_content"] || {};
} else { } else {