Skip to content

Commit e7556f9

Browse files
committed
MOBILE-3947 ng: Fix build errors
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
1 parent 444f8a9 commit e7556f9

File tree

17 files changed

+233
-133
lines changed

17 files changed

+233
-133
lines changed

package-lock.json

Lines changed: 32 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
"jest-preset-angular": "^13.1.4",
178178
"jsonc-parser": "^2.3.1",
179179
"keytar": "^7.2.0",
180-
"minimatch": "^5.1.0",
180+
"minimatch": "^9.0.3",
181181
"native-run": "^2.0.0",
182182
"patch-package": "^6.5.0",
183183
"ts-jest": "^29.1.1",

src/addons/mod/lesson/pages/user-retake/user-retake.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class AddonModLessonUserRetakePage implements OnInit {
218218
* @returns Formatted data.
219219
*/
220220
protected formatRetake(retakeData: AddonModLessonGetUserAttemptWSResponse): RetakeToDisplay {
221-
const formattedData = <RetakeToDisplay> retakeData;
221+
const formattedData = retakeData;
222222

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

234-
if (page.answerdata?.answers) {
235-
page.answerdata.answers.forEach((answer) => {
234+
contentPage.isContent = true;
235+
236+
if (contentPage.answerdata?.answers) {
237+
contentPage.answerdata.answers.forEach((answer) => {
236238
// Content pages only have 1 valid field in the answer array.
237239
answer[0] = AddonModLessonHelper.getContentPageAnswerDataFromHtml(answer[0]);
238240
});
239241
}
240242
} else if (AddonModLesson.answerPageIsQuestion(page)) {
241-
page.isQuestion = true;
243+
const questionPage = page as AnswerPage;
244+
245+
questionPage.isQuestion = true;
242246

243-
if (page.answerdata?.answers) {
244-
page.answerdata.answers.forEach((answer) => {
247+
if (questionPage.answerdata?.answers) {
248+
questionPage.answerdata.answers.forEach((answer) => {
245249
// Only the first field of the answer array requires to be parsed.
246250
answer[0] = AddonModLessonHelper.getQuestionPageAnswerDataFromHtml(answer[0]);
247251
});

src/addons/mod/lesson/services/lesson-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class AddonModLessonHelperProvider {
270270
if (option.checked || multiChoiceQuestion.multi) {
271271
// Add the control.
272272
const value = multiChoiceQuestion.multi ?
273-
{ value: option.checked, disabled: option.disabled } : option.value;
273+
{ value: option.checked, disabled: option.disabled } : option.checked;
274274
questionForm.addControl(option.name, this.formBuilder.control(value));
275275
controlAdded = true;
276276
}

src/addons/mod/scorm/services/scorm.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ export class AddonModScormProvider {
337337

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

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

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

373373
if (STATUSES[value] !== undefined) {
374374
value = STATUSES[value];
375375
}
376376

377-
if (matches[2] == '<>') {
377+
if (otherMatches[2] == '<>') {
378378
oper = '!=';
379379
} else {
380380
oper = '==';

src/app/app-routing.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
15+
import { InjectionToken, Injector, ModuleWithProviders, NgModule, Type } from '@angular/core';
1616
import {
1717
PreloadAllModules,
1818
RouterModule,
@@ -97,6 +97,12 @@ function buildConditionalUrlMatcher(pathOrMatcher: string | UrlMatcher, conditio
9797
};
9898
}
9999

100+
/**
101+
* Type to declare lazy route modules.
102+
*/
103+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
104+
export type LazyRoutesModule = Type<any>;
105+
100106
/**
101107
* Build url matcher using a regular expression.
102108
*

src/core/classes/application-init-status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { ApplicationInitStatus, APP_INITIALIZER, Injectable, Injector } from '@angular/core';
15+
import { ApplicationInitStatus, Injectable, Injector } from '@angular/core';
1616
import { setSingletonsInjector } from '@singletons';
1717

1818
@Injectable()
@@ -21,7 +21,7 @@ export class CoreApplicationInitStatus extends ApplicationInitStatus {
2121
constructor(injector: Injector) {
2222
setSingletonsInjector(injector);
2323

24-
super(injector.get(APP_INITIALIZER, []));
24+
super();
2525
}
2626

2727
whenDone(callback: () => unknown): void {

src/core/features/course/services/course-helper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import { CoreRemindersPushNotificationData } from '@features/reminders/services/
7575
import { CoreLocalNotifications } from '@services/local-notifications';
7676
import { CoreEnrol } from '@features/enrol/services/enrol';
7777
import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate';
78+
import { LazyRoutesModule } from '@/app/app-routing.module';
7879

7980
/**
8081
* Prefetch info of a module.
@@ -1990,7 +1991,7 @@ export class CoreCourseHelperProvider {
19901991
*
19911992
* @returns Course summary page module.
19921993
*/
1993-
async getCourseSummaryRouteModule(): Promise<unknown> {
1994+
async getCourseSummaryRouteModule(): Promise<LazyRoutesModule> {
19941995
return import('../course-summary-lazy.module').then(m => m.CoreCourseSummaryLazyModule);
19951996
}
19961997

src/core/features/courses/services/courses-helper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { of, firstValueFrom } from 'rxjs';
3030
import { zipIncludingComplete } from '@/core/utils/rxjs';
3131
import { catchError, map } from 'rxjs/operators';
3232
import { chainRequests, WSObservable } from '@classes/sites/authenticated-site';
33+
import { LazyRoutesModule } from '@/app/app-routing.module';
3334

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

0 commit comments

Comments
 (0)