Skip to content

Commit

Permalink
Merge pull request #28 from guardian/rc/return-types
Browse files Browse the repository at this point in the history
Added missing return types
  • Loading branch information
ripecosta authored Sep 10, 2019
2 parents 1cbec52 + 92fd3f6 commit 4641cfd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@guardian/consent-management-platform",
"version": "0.1.1",
"version": "0.2.0-rc.1",
"description": "Library of useful utilities for managing consent state across *.theguardian.com",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -30,8 +30,8 @@
"js-cookie": "^2.2.1"
},
"devDependencies": {
"@types/js-cookie": "^2.2.2",
"@types/jest": "^24.0.16",
"@types/js-cookie": "^2.2.2",
"@typescript-eslint/eslint-plugin": "^2.1.0",
"@typescript-eslint/parser": "^1.13.0",
"eslint": "^6.3.0",
Expand Down
37 changes: 21 additions & 16 deletions src/cmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ let cmpIsReady = false;
const buildGuPurposeRegister = (): GuPurposeRegister => {
const { purposes } = GU_PURPOSE_LIST;

const purposeRegister = purposes.reduce((register, purpose: GuPurpose) => {
if (purpose.alwaysEnabled) {
return register;
}

return {
...register,
[purpose.eventId]: {
state: null,
callbacks: [],
},
};
}, {});
const purposeRegister = purposes.reduce(
(register, purpose: GuPurpose): {} => {
if (purpose.alwaysEnabled) {
return register;
}

return {
...register,
[purpose.eventId]: {
state: null,
callbacks: [],
},
};
},
{},
);

return purposeRegister as GuPurposeRegister;
};
Expand All @@ -60,9 +63,11 @@ const triggerConsentNotification = (): void => {
);
});
// Iterate over iabPurposeRegister callbacks
iabPurposeRegister.callbacks.forEach(callback => {
callback(iabPurposeRegister.state);
});
iabPurposeRegister.callbacks.forEach(
(callback: IabPurposeCallback): void => {
callback(iabPurposeRegister.state);
},
);
};

const receiveMessage = (event: MessageEvent): void => {
Expand Down

0 comments on commit 4641cfd

Please sign in to comment.