Skip to content

Commit d775fa1

Browse files
alan-agius4dylhunn
authored andcommitted
refactor(common): modernize code in locale file (angular#52368)
Use `globalThis` global property contains the global this value, which is usually akin to the global object. PR Close angular#52368
1 parent 76152a5 commit d775fa1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/common/locales/generate-locales-tool/locale-global-file.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ export function generateLocaleGlobalFile(
2222
const extraLocaleData = generateLocaleExtraDataArrayCode(locale, localeData);
2323
const data = basicLocaleData.replace(/\]$/, `, ${extraLocaleData}]`);
2424
return `${fileHeader}
25-
(function(global) {
26-
global.ng = global.ng || {};
27-
global.ng.common = global.ng.common || {};
28-
global.ng.common.locales = global.ng.common.locales || {};
25+
(function() {
26+
globalThis.ng ??= {};
27+
globalThis.ng.common ??= {};
28+
globalThis.ng.common.locales ??= {};
2929
const u = undefined;
3030
${getPluralFunction(localeData, false)}
31-
global.ng.common.locales['${normalizeLocale(locale)}'] = ${data};
32-
})(typeof globalThis !== 'undefined' && globalThis || typeof global !== 'undefined' && global || typeof window !== 'undefined' && window);
31+
globalThis.ng.common.locales['${normalizeLocale(locale)}'] = ${data};
32+
})();
3333
`;
3434
}
3535

0 commit comments

Comments
 (0)