Skip to content

Commit 41b1a7c

Browse files
pkozlowski-opensourcealxhub
authored andcommitted
refactor(core): minor code cleanups (#59843)
Some minor code cleanups after code changes in previous commits. PR Close #59843
1 parent d8fca6d commit 41b1a7c

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

packages/core/src/render3/view/construction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function allocExpando(
2323
tView: TView,
2424
lView: LView,
2525
numSlotsToAlloc: number,
26-
initialValue: any,
26+
initialValue: unknown,
2727
): number {
2828
if (numSlotsToAlloc === 0) return -1;
2929
if (ngDevMode) {

packages/core/src/render3/view/directives.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function resolveDirectives(
6666
// tsickle.
6767
ngDevMode && assertFirstCreatePass(tView);
6868

69-
const exportsMap: {[key: string]: number} | null = localRefs === null ? null : {'': -1};
69+
const exportsMap: Record<string, number> | null = localRefs === null ? null : {'': -1};
7070
const matchedDirectiveDefs = directiveMatcher(tView, tNode);
7171

7272
if (matchedDirectiveDefs !== null) {
@@ -77,30 +77,30 @@ export function resolveDirectives(
7777
);
7878
initializeDirectives(tView, lView, tNode, directiveDefs, exportsMap, hostDirectiveDefs);
7979
}
80-
if (exportsMap) cacheMatchingLocalNames(tNode, localRefs, exportsMap);
80+
if (exportsMap !== null && localRefs !== null) {
81+
cacheMatchingLocalNames(tNode, localRefs, exportsMap);
82+
}
8183
}
8284

8385
/** Caches local names and their matching directive indices for query and template lookups. */
8486
function cacheMatchingLocalNames(
8587
tNode: TNode,
86-
localRefs: string[] | null,
88+
localRefs: string[],
8789
exportsMap: {[key: string]: number},
8890
): void {
89-
if (localRefs) {
90-
const localNames: (string | number)[] = (tNode.localNames = []);
91-
92-
// Local names must be stored in tNode in the same order that localRefs are defined
93-
// in the template to ensure the data is loaded in the same slots as their refs
94-
// in the template (for template queries).
95-
for (let i = 0; i < localRefs.length; i += 2) {
96-
const index = exportsMap[localRefs[i + 1]];
97-
if (index == null)
98-
throw new RuntimeError(
99-
RuntimeErrorCode.EXPORT_NOT_FOUND,
100-
ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`,
101-
);
102-
localNames.push(localRefs[i], index);
103-
}
91+
const localNames: (string | number)[] = (tNode.localNames = []);
92+
93+
// Local names must be stored in tNode in the same order that localRefs are defined
94+
// in the template to ensure the data is loaded in the same slots as their refs
95+
// in the template (for template queries).
96+
for (let i = 0; i < localRefs.length; i += 2) {
97+
const index = exportsMap[localRefs[i + 1]];
98+
if (index == null)
99+
throw new RuntimeError(
100+
RuntimeErrorCode.EXPORT_NOT_FOUND,
101+
ngDevMode && `Export of name '${localRefs[i + 1]}' not found!`,
102+
);
103+
localNames.push(localRefs[i], index);
104104
}
105105
}
106106

@@ -281,8 +281,6 @@ function initializeInputAndOutputAliases(
281281
);
282282
// Do not use unbound attributes as inputs to structural directives, since structural
283283
// directive inputs can only be set using microsyntax (e.g. `<div *dir="exp">`).
284-
// TODO(FW-1930): microsyntax expressions may also contain unbound/static attributes, which
285-
// should be set for inline templates.
286284
const initialInputs =
287285
inputsStore !== null && tNodeAttrs !== null && !isInlineTemplate(tNode)
288286
? generateInitialInputs(inputsStore, directiveIndex, tNodeAttrs)

0 commit comments

Comments
 (0)