You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Enable noImplicitAny (#2895)
* Stash noImplicitAny work * Enable noImplicitAny * Update olm * Fun * Fix msgid stuff * Fix tests * Attempt to fix Browserify
This commit is contained in:
committed by
GitHub
parent
6f81371e61
commit
8d018f9c2d
16
src/utils.ts
16
src/utils.ts
@@ -316,7 +316,7 @@ export function deepSortedObjectEntries(obj: any): [string, any][] {
|
||||
* @param {*} value the value to test
|
||||
* @return {boolean} whether or not value is a finite number without type-coercion
|
||||
*/
|
||||
export function isNumber(value: any): boolean {
|
||||
export function isNumber(value: any): value is number {
|
||||
return typeof value === 'number' && isFinite(value);
|
||||
}
|
||||
|
||||
@@ -428,8 +428,8 @@ export interface IDeferred<T> {
|
||||
|
||||
// Returns a Deferred
|
||||
export function defer<T = void>(): IDeferred<T> {
|
||||
let resolve;
|
||||
let reject;
|
||||
let resolve!: IDeferred<T>["resolve"];
|
||||
let reject!: IDeferred<T>["reject"];
|
||||
|
||||
const promise = new Promise<T>((_resolve, _reject) => {
|
||||
resolve = _resolve;
|
||||
@@ -665,18 +665,22 @@ export function compare(a: string, b: string): number {
|
||||
* @param {Object} source
|
||||
* @returns the target object
|
||||
*/
|
||||
export function recursivelyAssign(target: Object, source: Object, ignoreNullish = false): any {
|
||||
export function recursivelyAssign<T1 extends T2, T2 extends Record<string, any>>(
|
||||
target: T1,
|
||||
source: T2,
|
||||
ignoreNullish = false,
|
||||
): T1 & T2 {
|
||||
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
||||
if (target[sourceKey] instanceof Object && sourceValue) {
|
||||
recursivelyAssign(target[sourceKey], sourceValue);
|
||||
continue;
|
||||
}
|
||||
if ((sourceValue !== null && sourceValue !== undefined) || !ignoreNullish) {
|
||||
target[sourceKey] = sourceValue;
|
||||
target[sourceKey as keyof T1] = sourceValue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return target;
|
||||
return target as T1 & T2;
|
||||
}
|
||||
|
||||
function getContentTimestampWithFallback(event: MatrixEvent): number {
|
||||
|
||||
Reference in New Issue
Block a user