Skip to content

Commit 5884153

Browse files
arturovtkirjs
authored andcommitted
refactor(animations): drop warning functions in production (angular#59408)
Prior to this commit, functions that issued warnings were not wrapped with `ngDevMode` at the point of invocation but had the `ngDevMode` check inside. This meant they acted as no-ops in production. In this commit, we wrap them externally with `ngDevMode`, so they are entirely removed. PR Close angular#59408
1 parent 1723421 commit 5884153

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

packages/animations/browser/src/dsl/animation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ export class Animation {
3535
if (errors.length) {
3636
throw validationFailed(errors);
3737
}
38-
if (warnings.length) {
39-
warnValidation(warnings);
38+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
39+
if (warnings.length) {
40+
warnValidation(warnings);
41+
}
4042
}
4143
this._animationAst = ast;
4244
}

packages/animations/browser/src/render/animation_engine_next.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ export class AnimationEngine {
6161
if (errors.length) {
6262
throw triggerBuildFailed(name, errors);
6363
}
64-
if (warnings.length) {
65-
warnTriggerBuild(name, warnings);
64+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
65+
if (warnings.length) {
66+
warnTriggerBuild(name, warnings);
67+
}
6668
}
6769
trigger = buildTrigger(name, ast, this._normalizer);
6870
this._triggerCache[cacheKey] = trigger;

packages/animations/browser/src/render/timeline_animation_engine.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ export class TimelineAnimationEngine {
5858
if (errors.length) {
5959
throw registerFailed(errors);
6060
} else {
61-
if (warnings.length) {
62-
warnRegister(warnings);
61+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
62+
if (warnings.length) {
63+
warnRegister(warnings);
64+
}
6365
}
6466
this._animations.set(id, ast);
6567
}

packages/animations/browser/src/warning_helpers.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,27 @@ function createListOfWarnings(warnings: string[]): string {
1515
}
1616

1717
export function warnValidation(warnings: string[]): void {
18-
(typeof ngDevMode === 'undefined' || ngDevMode) &&
19-
console.warn(`animation validation warnings:${createListOfWarnings(warnings)}`);
18+
console.warn(`animation validation warnings:${createListOfWarnings(warnings)}`);
2019
}
2120

2221
export function warnTriggerBuild(name: string, warnings: string[]): void {
23-
(typeof ngDevMode === 'undefined' || ngDevMode) &&
24-
console.warn(
25-
`The animation trigger "${name}" has built with the following warnings:${createListOfWarnings(
26-
warnings,
27-
)}`,
28-
);
22+
console.warn(
23+
`The animation trigger "${name}" has built with the following warnings:${createListOfWarnings(
24+
warnings,
25+
)}`,
26+
);
2927
}
3028

3129
export function warnRegister(warnings: string[]): void {
32-
(typeof ngDevMode === 'undefined' || ngDevMode) &&
33-
console.warn(`Animation built with the following warnings:${createListOfWarnings(warnings)}`);
30+
console.warn(`Animation built with the following warnings:${createListOfWarnings(warnings)}`);
3431
}
3532

3633
export function triggerParsingWarnings(name: string, warnings: string[]): void {
37-
(typeof ngDevMode === 'undefined' || ngDevMode) &&
38-
console.warn(
39-
`Animation parsing for the ${name} trigger presents the following warnings:${createListOfWarnings(
40-
warnings,
41-
)}`,
42-
);
34+
console.warn(
35+
`Animation parsing for the ${name} trigger presents the following warnings:${createListOfWarnings(
36+
warnings,
37+
)}`,
38+
);
4339
}
4440

4541
export function pushUnrecognizedPropertiesWarning(warnings: string[], props: string[]): void {

0 commit comments

Comments
 (0)