Skip to content

Commit

Permalink
MOBILE-3947 ng: Fix build errors
Browse files Browse the repository at this point in the history
Target in app tsconfig is set to es2022 by the Angular CLI, so we must
set it as well to be consistent in the rest of the tooling. Angular
compilation later uses browserslist for further transpilations.

Target in unit tests is kept at es2016 because of a known bug in
Angular: angular/angular#31730
  • Loading branch information
NoelDeMartin committed Nov 29, 2023
1 parent 7f630b2 commit 2449aca
Show file tree
Hide file tree
Showing 17 changed files with 233 additions and 133 deletions.
97 changes: 32 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"jest-preset-angular": "^13.1.4",
"jsonc-parser": "^2.3.1",
"keytar": "^7.2.0",
"minimatch": "^5.1.0",
"minimatch": "^9.0.3",
"native-run": "^2.0.0",
"patch-package": "^6.5.0",
"ts-jest": "^29.1.1",
Expand Down
18 changes: 11 additions & 7 deletions src/addons/mod/lesson/pages/user-retake/user-retake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
* @returns Formatted data.
*/
protected formatRetake(retakeData: AddonModLessonGetUserAttemptWSResponse): RetakeToDisplay {
const formattedData = <RetakeToDisplay> retakeData;
const formattedData = retakeData;

if (formattedData.userstats.gradeinfo) {
// Completed.
Expand All @@ -229,19 +229,23 @@ export class AddonModLessonUserRetakePage implements OnInit {
// Format pages data.
formattedData.answerpages.forEach((page) => {
if (AddonModLesson.answerPageIsContent(page)) {
page.isContent = true;
const contentPage = page as AnswerPage;

if (page.answerdata?.answers) {
page.answerdata.answers.forEach((answer) => {
contentPage.isContent = true;

if (contentPage.answerdata?.answers) {
contentPage.answerdata.answers.forEach((answer) => {
// Content pages only have 1 valid field in the answer array.
answer[0] = AddonModLessonHelper.getContentPageAnswerDataFromHtml(answer[0]);
});
}
} else if (AddonModLesson.answerPageIsQuestion(page)) {
page.isQuestion = true;
const questionPage = page as AnswerPage;

questionPage.isQuestion = true;

if (page.answerdata?.answers) {
page.answerdata.answers.forEach((answer) => {
if (questionPage.answerdata?.answers) {
questionPage.answerdata.answers.forEach((answer) => {
// Only the first field of the answer array requires to be parsed.
answer[0] = AddonModLessonHelper.getQuestionPageAnswerDataFromHtml(answer[0]);
});
Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/lesson/services/lesson-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class AddonModLessonHelperProvider {
if (option.checked || multiChoiceQuestion.multi) {
// Add the control.
const value = multiChoiceQuestion.multi ?
{ value: option.checked, disabled: option.disabled } : option.value;
{ value: option.checked, disabled: option.disabled } : option.checked;
questionForm.addControl(option.name, this.formBuilder.control(value));
controlAdded = true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/addons/mod/scorm/services/scorm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class AddonModScormProvider {

const re = /^(\d+)\*\{(.+)\}$/; // Sets like 3*{S34, S36, S37, S39}.
const reOther = /^(.+)(=|<>)(.+)$/; // Other symbols.
let matches = element.match(re);
const matches = element.match(re);

if (matches) {
const repeat = Number(matches[1]);
Expand All @@ -363,18 +363,18 @@ export class AddonModScormProvider {
element = '!';
} else if (reOther.test(element)) {
// Other symbols = | <> .
matches = element.match(reOther) ?? [];
element = matches[1]?.trim();
const otherMatches = element.match(reOther) ?? [];
element = otherMatches[1]?.trim();

if (trackData[element] !== undefined) {
let value = matches[3].trim().replace(/('|")/gi, '');
let value = otherMatches[3].trim().replace(/('|")/gi, '');
let oper: string;

if (STATUSES[value] !== undefined) {
value = STATUSES[value];
}

if (matches[2] == '<>') {
if (otherMatches[2] == '<>') {
oper = '!=';
} else {
oper = '==';
Expand Down
8 changes: 7 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
import { InjectionToken, Injector, ModuleWithProviders, NgModule, Type } from '@angular/core';
import {
PreloadAllModules,
RouterModule,
Expand Down Expand Up @@ -97,6 +97,12 @@ function buildConditionalUrlMatcher(pathOrMatcher: string | UrlMatcher, conditio
};
}

/**
* Type to declare lazy route modules.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type LazyRoutesModule = Type<any>;

/**
* Build url matcher using a regular expression.
*
Expand Down
4 changes: 2 additions & 2 deletions src/core/classes/application-init-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { ApplicationInitStatus, APP_INITIALIZER, Injectable, Injector } from '@angular/core';
import { ApplicationInitStatus, Injectable, Injector } from '@angular/core';
import { setSingletonsInjector } from '@singletons';

@Injectable()
Expand All @@ -21,7 +21,7 @@ export class CoreApplicationInitStatus extends ApplicationInitStatus {
constructor(injector: Injector) {
setSingletonsInjector(injector);

super(injector.get(APP_INITIALIZER, []));
super();
}

whenDone(callback: () => unknown): void {
Expand Down
3 changes: 2 additions & 1 deletion src/core/features/course/services/course-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import { CoreRemindersPushNotificationData } from '@features/reminders/services/
import { CoreLocalNotifications } from '@services/local-notifications';
import { CoreEnrol } from '@features/enrol/services/enrol';
import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate';
import { LazyRoutesModule } from '@/app/app-routing.module';

/**
* Prefetch info of a module.
Expand Down Expand Up @@ -1990,7 +1991,7 @@ export class CoreCourseHelperProvider {
*
* @returns Course summary page module.
*/
async getCourseSummaryRouteModule(): Promise<unknown> {
async getCourseSummaryRouteModule(): Promise<LazyRoutesModule> {
return import('../course-summary-lazy.module').then(m => m.CoreCourseSummaryLazyModule);
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/features/courses/services/courses-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { of, firstValueFrom } from 'rxjs';
import { zipIncludingComplete } from '@/core/utils/rxjs';
import { catchError, map } from 'rxjs/operators';
import { chainRequests, WSObservable } from '@classes/sites/authenticated-site';
import { LazyRoutesModule } from '@/app/app-routing.module';

// Id for a course item representing all courses (for example, for course filters).
export const ALL_COURSES_ID = -1;
Expand Down Expand Up @@ -432,7 +433,7 @@ export class CoreCoursesHelperProvider {
*
* @returns My courses page module.
*/
async getMyRouteModule(): Promise<unknown> {
async getMyRouteModule(): Promise<LazyRoutesModule> {
return import('../courses-my-lazy.module').then(m => m.CoreCoursesMyLazyModule);
}

Expand Down
Loading

0 comments on commit 2449aca

Please sign in to comment.