MOBILE-3947 chore: Fix TS errors
parent
af215a7f5c
commit
4286234e6b
|
@ -125,7 +125,7 @@ export class CoreDatabaseTable<
|
|||
}
|
||||
|
||||
const sorting = options?.sorting
|
||||
&& this.normalizedSorting(options.sorting).map(([column, direction]) => `${column} ${direction}`).join(', ');
|
||||
&& this.normalizedSorting(options.sorting).map(([column, direction]) => `${column.toString()} ${direction}`).join(', ');
|
||||
|
||||
return this.database.getRecords(this.tableName, conditions, sorting, '*', options?.offset, options?.limit);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export abstract class CorePromise<T = unknown> implements Promise<T> {
|
|||
this.nativePromise = nativePromise;
|
||||
}
|
||||
|
||||
[Symbol.toStringTag]: string;
|
||||
[Symbol.toStringTag]!: string;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
|
|
@ -238,11 +238,11 @@ export class CoreCourseProvider {
|
|||
}
|
||||
|
||||
const course = await CoreCourses.getCourseByField('id', courseId, site.id);
|
||||
const formatOptions = CoreUtils.objectToKeyValueMap<{ indentation?: string }>(
|
||||
const formatOptions = CoreUtils.objectToKeyValueMap(
|
||||
course.courseformatoptions ?? [],
|
||||
'name',
|
||||
'value',
|
||||
);
|
||||
) as { indentation?: string };
|
||||
|
||||
return formatOptions.indentation === '1';
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ export class CoreCourseFormatDelegateService extends CoreDelegate<CoreCourseForm
|
|||
[course, sections],
|
||||
);
|
||||
|
||||
if (sectionData && 'forceSelected' in sectionData) {
|
||||
if (sectionData && typeof sectionData === 'object' && 'forceSelected' in sectionData) {
|
||||
return sectionData;
|
||||
} else if (sectionData) {
|
||||
// Function just returned the section, don't force selecting it.
|
||||
|
|
|
@ -636,7 +636,10 @@ export class CoreCoursesProvider {
|
|||
ignoreErrors(this.getUserNavigationOptionsObservable(courseIds, options), {}),
|
||||
ignoreErrors(this.getUserAdministrationOptionsObservable(courseIds, options), {}),
|
||||
).pipe(
|
||||
map(([navOptions, admOptions]) => ({ navOptions, admOptions })),
|
||||
map(([navOptions, admOptions]) => ({
|
||||
navOptions: navOptions as CoreCourseUserAdminOrNavOptionCourseIndexed,
|
||||
admOptions: admOptions as CoreCourseUserAdminOrNavOptionCourseIndexed,
|
||||
})),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -933,7 +933,8 @@ export class CoreFileProvider {
|
|||
// If destFolder is not set, use same location as ZIP file. We need to use absolute paths (including basePath).
|
||||
destFolder = this.addBasePathIfNeeded(destFolder || CoreMimetypeUtils.removeExtension(path));
|
||||
|
||||
const result = await Zip.unzip(fileEntry.toURL(), destFolder, onProgress);
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const result = await Zip.unzip(fileEntry.toURL(), destFolder, onProgress as unknown as Function);
|
||||
|
||||
if (result == -1) {
|
||||
throw new CoreError('Unzip failed.');
|
||||
|
|
|
@ -136,7 +136,7 @@ export class CoreNavigatorService {
|
|||
animated: options.animated,
|
||||
animation: options.animation,
|
||||
animationDirection: options.animationDirection,
|
||||
queryParams: CoreObject.isEmpty(options.params ?? {}) ? null : CoreObject.withoutEmpty(options.params),
|
||||
queryParams: CoreObject.isEmpty(options.params ?? {}) ? null : CoreObject.withoutEmpty(options.params ?? {}),
|
||||
relativeTo: path.startsWith('/') ? null : this.getCurrentRoute(),
|
||||
replaceUrl: options.replace,
|
||||
});
|
||||
|
|
|
@ -1405,7 +1405,7 @@ export class CoreUtilsProvider {
|
|||
* @param enumeration Enumeration object.
|
||||
* @returns Keys of the enumeration.
|
||||
*/
|
||||
enumKeys<O, K extends keyof O = keyof O>(enumeration: O): K[] {
|
||||
enumKeys<O extends object, K extends keyof O = keyof O>(enumeration: O): K[] {
|
||||
return Object.keys(enumeration).filter(k => Number.isNaN(+k)) as K[];
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ export function setCreateSingletonMethodProxy(method: typeof createSingletonMeth
|
|||
* defined using a class or the string used in the `provide` key if it was defined using an object.
|
||||
* @returns Singleton proxy.
|
||||
*/
|
||||
export function makeSingleton<Service extends object = object>( // eslint-disable-line @typescript-eslint/ban-types
|
||||
export function makeSingleton<Service extends object = object>(
|
||||
injectionToken: Type<Service> | AbstractType<Service> | Type<unknown> | string,
|
||||
): CoreSingletonProxy<Service> {
|
||||
const singleton = {
|
||||
|
|
|
@ -66,7 +66,7 @@ function expectBool (str) {
|
|||
throw SyntaxError('Invalid bool value, expected 0 or 1')
|
||||
}
|
||||
|
||||
return [ boolMatch === '1', match.length ]
|
||||
return [ boolMatch === '1', match?.length ]
|
||||
}
|
||||
|
||||
function expectInt (str) {
|
||||
|
@ -77,7 +77,7 @@ function expectInt (str) {
|
|||
throw SyntaxError('Expected an integer value')
|
||||
}
|
||||
|
||||
return [ parseInt(intMatch, 10), match.length ]
|
||||
return [ parseInt(intMatch, 10), match?.length ]
|
||||
}
|
||||
|
||||
function expectFloat (str) {
|
||||
|
@ -105,7 +105,7 @@ function expectFloat (str) {
|
|||
break
|
||||
}
|
||||
|
||||
return [ floatValue, match.length ]
|
||||
return [ floatValue, match?.length ]
|
||||
}
|
||||
|
||||
function readBytes (str, len, escapedString = false) {
|
||||
|
@ -260,7 +260,9 @@ function expectObject (str, cache) {
|
|||
str = str.substring(value[1])
|
||||
totalOffset += value[1]
|
||||
|
||||
obj[prop[0]] = value[0]
|
||||
if (prop[0]) {
|
||||
obj[prop[0]] = value[0]
|
||||
}
|
||||
}
|
||||
|
||||
// strict parsing, expect } after object literal
|
||||
|
@ -299,7 +301,7 @@ function expectArray (str, cache) {
|
|||
throw SyntaxError('Expected array length annotation')
|
||||
}
|
||||
|
||||
str = str.substring(arrayLiteralBeginMatch.length)
|
||||
str = str.substring(arrayLiteralBeginMatch?.length)
|
||||
|
||||
const array = expectArrayItems(str, parseInt(arrayLengthMatch, 10), cache)
|
||||
|
||||
|
@ -308,7 +310,7 @@ function expectArray (str, cache) {
|
|||
throw SyntaxError('Expected }')
|
||||
}
|
||||
|
||||
return [ array[0], arrayLiteralBeginMatch.length + (array[1] as number) + 1 ] // jump over }
|
||||
return [ array[0], arrayLiteralBeginMatch?.length ?? 0 + (array[1] as number) + 1 ] // jump over }
|
||||
}
|
||||
|
||||
function expectArrayItems (str, expectedItems = 0, cache) {
|
||||
|
|
|
@ -91,9 +91,9 @@ export class CoreObject {
|
|||
* @param keysOrRegex If array is supplied, keys to include. Otherwise, regular expression used to filter keys.
|
||||
* @returns New object with only the specified keys.
|
||||
*/
|
||||
static only<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
||||
static only<T>(obj: T, regex: RegExp): Partial<T>;
|
||||
static only<T, K extends keyof T>(obj: T, keysOrRegex: K[] | RegExp): Pick<T, K> | Partial<T> {
|
||||
static only<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
||||
static only<T extends object>(obj: T, regex: RegExp): Partial<T>;
|
||||
static only<T extends object, K extends keyof T>(obj: T, keysOrRegex: K[] | RegExp): Pick<T, K> | Partial<T> {
|
||||
const newObject: Partial<T> = {};
|
||||
|
||||
if (Array.isArray(keysOrRegex)) {
|
||||
|
@ -136,7 +136,7 @@ export class CoreObject {
|
|||
* @param obj Objet.
|
||||
* @returns New object without empty values.
|
||||
*/
|
||||
static withoutEmpty<T>(obj: T): CoreObjectWithoutEmpty<T> {
|
||||
static withoutEmpty<T extends object>(obj: T): CoreObjectWithoutEmpty<T> {
|
||||
const cleanObj = {};
|
||||
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
|
@ -156,7 +156,7 @@ export class CoreObject {
|
|||
* @param obj Objet.
|
||||
* @returns New object without undefined values.
|
||||
*/
|
||||
static withoutUndefined<T>(obj: T): CoreObjectWithoutUndefined<T> {
|
||||
static withoutUndefined<T extends object>(obj: T): CoreObjectWithoutUndefined<T> {
|
||||
const cleanObj = {};
|
||||
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
|
|
Loading…
Reference in New Issue