mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Explicitly adding an `export {}` to modules containing declare global fixes an issue where Rollup would incorrectly claim that the global variable is not defined in the emitted .d.ts files.
Needed to land the latest rules_angular.
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
/*!
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
*/
|
|
|
|
declare global {
|
|
interface Window {
|
|
gtag?(...args: any[]): void;
|
|
}
|
|
}
|
|
|
|
export const setCookieConsent = (state: 'denied' | 'granted'): void => {
|
|
try {
|
|
if (window.gtag) {
|
|
const consentOptions = {
|
|
ad_user_data: state,
|
|
ad_personalization: state,
|
|
ad_storage: state,
|
|
analytics_storage: state,
|
|
};
|
|
|
|
if (state === 'denied') {
|
|
window.gtag('consent', 'default', {
|
|
...consentOptions,
|
|
wait_for_update: 500,
|
|
});
|
|
} else if (state === 'granted') {
|
|
window.gtag('consent', 'update', {
|
|
...consentOptions,
|
|
});
|
|
}
|
|
}
|
|
} catch {
|
|
if (state === 'denied') {
|
|
console.error('Unable to set default cookie consent.');
|
|
} else if (state === 'granted') {
|
|
console.error('Unable to grant cookie consent.');
|
|
}
|
|
}
|
|
};
|
|
|
|
// This fixes the RollupError: Exported variable "global" is not defined.
|
|
export {};
|