refactor(ivy): ngcc - use .has()
to check Map membership (#25445)
Previously we were relying upon the `.get()` method to return `undefined` but it is clearer and safer to always check with `.has()` first. PR Close #25445
This commit is contained in:

committed by
Jason Aden

parent
edd775eabc
commit
757d4c33df
@ -63,7 +63,7 @@ export class ModuleWithProvidersAnalyzer {
|
||||
ngModule = {node: dtsNgModule, viaModule: null};
|
||||
}
|
||||
const dtsFile = dtsFn.getSourceFile();
|
||||
const analysis = analyses.get(dtsFile) || [];
|
||||
const analysis = analyses.has(dtsFile) ? analyses.get(dtsFile) : [];
|
||||
analysis.push({declaration: dtsFn, ngModule});
|
||||
analyses.set(dtsFile, analysis);
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ export class PrivateDeclarationsAnalyzer {
|
||||
if (exports) {
|
||||
exports.forEach((declaration, exportedName) => {
|
||||
if (hasNameIdentifier(declaration.node)) {
|
||||
const privateDeclaration = privateDeclarations.get(declaration.node.name);
|
||||
if (privateDeclaration) {
|
||||
if (privateDeclarations.has(declaration.node.name)) {
|
||||
const privateDeclaration = privateDeclarations.get(declaration.node.name) !;
|
||||
if (privateDeclaration.node !== declaration.node) {
|
||||
throw new Error(`${declaration.node.name.text} is declared multiple times.`);
|
||||
}
|
||||
@ -96,7 +96,7 @@ export class PrivateDeclarationsAnalyzer {
|
||||
return Array.from(privateDeclarations.keys()).map(id => {
|
||||
const from = AbsoluteFsPath.fromSourceFile(id.getSourceFile());
|
||||
const declaration = privateDeclarations.get(id) !;
|
||||
const alias = exportAliasDeclarations.get(id) || null;
|
||||
const alias = exportAliasDeclarations.has(id) ? exportAliasDeclarations.get(id) ! : null;
|
||||
const dtsDeclaration = this.host.getDtsDeclaration(declaration.node);
|
||||
const dtsFrom =
|
||||
dtsDeclaration && AbsoluteFsPath.fromSourceFile(dtsDeclaration.getSourceFile());
|
||||
|
Reference in New Issue
Block a user