Skip to content

Commit ae3acca

Browse files
pmvalddylhunn
authored andcommitted
refactor(compiler-cli): remove unnecessary compilationMode args (#52215)
After previous commits, some `compilationMode` args in some helper functions became unused. In this change those args are cleaned up. PR Close #52215
1 parent 56a76d7 commit ae3acca

File tree

6 files changed

+16
-23
lines changed

6 files changed

+16
-23
lines changed

packages/compiler-cli/src/ngtsc/annotations/common/src/di.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Expression, LiteralExpr, R3DependencyMetadata, ReadPropExpr, WrappedNodeExpr} from '@angular/compiler';
9+
import {Expression, LiteralExpr, R3DependencyMetadata, WrappedNodeExpr} from '@angular/compiler';
1010
import ts from 'typescript';
1111

1212
import {ErrorCode, FatalDiagnosticError, makeRelatedInformation} from '../../../diagnostics';
1313
import {ClassDeclaration, CtorParameter, ReflectionHost, TypeValueReferenceKind, UnavailableValue, ValueUnavailableKind,} from '../../../reflection';
14-
import {CompilationMode} from '../../../transform';
1514

1615
import {isAngularCore, valueReferenceToExpression} from './util';
1716

17+
1818
export type ConstructorDeps = {
1919
deps: R3DependencyMetadata[];
2020
}|{
@@ -29,8 +29,7 @@ export interface ConstructorDepError {
2929
}
3030

3131
export function getConstructorDependencies(
32-
clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean,
33-
compilationMode: CompilationMode): ConstructorDeps|null {
32+
clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): ConstructorDeps|null {
3433
const deps: R3DependencyMetadata[] = [];
3534
const errors: ConstructorDepError[] = [];
3635
let ctorParams = reflector.getConstructorParameters(clazz);
@@ -126,10 +125,10 @@ export function unwrapConstructorDependencies(deps: ConstructorDeps|null): R3Dep
126125
}
127126

128127
export function getValidConstructorDependencies(
129-
clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean,
130-
compilationMode: CompilationMode): R3DependencyMetadata[]|null {
128+
clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): R3DependencyMetadata[]|
129+
null {
131130
return validateConstructorDependencies(
132-
clazz, getConstructorDependencies(clazz, reflector, isCore, compilationMode));
131+
clazz, getConstructorDependencies(clazz, reflector, isCore));
133132
}
134133

135134
/**

packages/compiler-cli/src/ngtsc/annotations/common/src/injectable_registry.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {R3DependencyMetadata} from '@angular/compiler';
99

1010
import {hasInjectableFields} from '../../../metadata';
1111
import {ClassDeclaration, ReflectionHost} from '../../../reflection';
12-
import {CompilationMode} from '../../../transform';
1312

1413
import {getConstructorDependencies, unwrapConstructorDependencies} from './di';
1514

@@ -43,8 +42,7 @@ export class InjectableClassRegistry {
4342
return null;
4443
}
4544

46-
const ctorDeps =
47-
getConstructorDependencies(declaration, this.host, this.isCore, CompilationMode.FULL);
45+
const ctorDeps = getConstructorDependencies(declaration, this.host, this.isCore);
4846
const meta: InjectableMeta = {
4947
ctorDeps: unwrapConstructorDependencies(ctorDeps),
5048
};

packages/compiler-cli/src/ngtsc/annotations/directive/src/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export function extractDirectiveMetadata(
156156
exportAs = resolved.split(',').map(part => part.trim());
157157
}
158158

159-
const rawCtorDeps = getConstructorDependencies(clazz, reflector, isCore, compilationMode);
159+
const rawCtorDeps = getConstructorDependencies(clazz, reflector, isCore);
160160

161161
// Non-abstract directives (those with a selector) require valid constructor dependencies, whereas
162162
// abstract directives are allowed to have invalid dependencies, given that a subclass may call

packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ export class NgModuleDecoratorHandler implements
468468
name,
469469
type,
470470
typeArgumentCount: 0,
471-
deps:
472-
getValidConstructorDependencies(node, this.reflector, this.isCore, this.compilationMode),
471+
deps: getValidConstructorDependencies(node, this.reflector, this.isCore),
473472
target: FactoryTarget.NgModule,
474473
};
475474

packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ export class InjectableDecoratorHandler implements
7272
analysis: {
7373
meta,
7474
ctorDeps: extractInjectableCtorDeps(
75-
node, meta, decorator, this.reflector, this.isCore, this.strictCtorDeps,
76-
this.compilationMode),
75+
node, meta, decorator, this.reflector, this.isCore, this.strictCtorDeps),
7776
classMetadata: this.includeClassMetadata ?
7877
extractClassMetadata(node, this.reflector, this.isCore) :
7978
null,
@@ -258,8 +257,7 @@ function getProviderExpression(
258257

259258
function extractInjectableCtorDeps(
260259
clazz: ClassDeclaration, meta: R3InjectableMetadata, decorator: Decorator,
261-
reflector: ReflectionHost, isCore: boolean, strictCtorDeps: boolean,
262-
compilationMode: CompilationMode) {
260+
reflector: ReflectionHost, isCore: boolean, strictCtorDeps: boolean) {
263261
if (decorator.args === null) {
264262
throw new FatalDiagnosticError(
265263
ErrorCode.DECORATOR_NOT_CALLED, decorator.node, '@Injectable must be called');
@@ -277,15 +275,15 @@ function extractInjectableCtorDeps(
277275
// constructor signature does not work for DI then a factory definition (ɵfac) that throws is
278276
// generated.
279277
if (strictCtorDeps && !isAbstractClassDeclaration(clazz)) {
280-
ctorDeps = getValidConstructorDependencies(clazz, reflector, isCore, compilationMode);
278+
ctorDeps = getValidConstructorDependencies(clazz, reflector, isCore);
281279
} else {
282-
ctorDeps = unwrapConstructorDependencies(
283-
getConstructorDependencies(clazz, reflector, isCore, compilationMode));
280+
ctorDeps =
281+
unwrapConstructorDependencies(getConstructorDependencies(clazz, reflector, isCore));
284282
}
285283

286284
return ctorDeps;
287285
} else if (decorator.args.length === 1) {
288-
const rawCtorDeps = getConstructorDependencies(clazz, reflector, isCore, compilationMode);
286+
const rawCtorDeps = getConstructorDependencies(clazz, reflector, isCore);
289287

290288
if (strictCtorDeps && !isAbstractClassDeclaration(clazz) && requiresValidCtor(meta)) {
291289
// Since use* was not provided for a concrete class, validate the deps according to

packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ export class PipeDecoratorHandler implements
135135
type,
136136
typeArgumentCount: this.reflector.getGenericArityOfClass(clazz) || 0,
137137
pipeName,
138-
deps: getValidConstructorDependencies(
139-
clazz, this.reflector, this.isCore, this.compilationMode),
138+
deps: getValidConstructorDependencies(clazz, this.reflector, this.isCore),
140139
pure,
141140
isStandalone,
142141
},

0 commit comments

Comments
 (0)