Skip to content

Commit

Permalink
Style: Always define types before use and do not warn for unused vars…
Browse files Browse the repository at this point in the history
… in exported types
  • Loading branch information
OndraM committed Apr 9, 2024
1 parent 8842da9 commit 05d7ce6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/types/CookieConsentManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CookieConsentCategory, DisplayMode, SecondaryButtonMode } from '../constants';
import { VanillaCookieConsent } from './vanilla-cookieconsent';

/* eslint-disable no-unused-vars */
export type Values<T> = T[keyof T];

export type CookieConsentCategoryValues = Values<typeof CookieConsentCategory>;
Expand All @@ -26,14 +27,14 @@ export type TranslationOverride = {
settingsModalMoreInfo?: string;
};

export type CookieTable = {
[language: string]: CookieTableCategories;
};

export type CookieTableCategories = {
[category in CookieConsentCategoryValues]: VanillaCookieConsent.CookieTableItem[];
};

export type CookieTable = {
[language: string]: CookieTableCategories;
};

export type CookieConsentManagerOptions = {
defaultLang: string;
autodetectLang: boolean;
Expand All @@ -53,3 +54,4 @@ export type CookieConsentManager = (
serviceName: string,
args?: Partial<CookieConsentManagerOptions>,
) => VanillaCookieConsent.CookieConsent<CookieConsentCategoryValues>;
/* eslint-enable no-unused-vars */
2 changes: 2 additions & 0 deletions src/types/Messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable no-unused-vars */
export interface ExtraMessages {
companyNames: string[];
consentTitle?: string;
descriptionIntro?: string;
settingsModalMoreInfo?: string;
}
/* eslint-enable no-unused-vars */
26 changes: 14 additions & 12 deletions src/types/vanilla-cookieconsent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
export namespace VanillaCookieConsent {
export interface Cookie<Category> {
data: any;
Expand All @@ -6,6 +7,18 @@ export namespace VanillaCookieConsent {
rfc_cookie: boolean;
}

export enum AcceptType {
ALL = 'all',
NECESSARY = 'necessary',
CUSTOM = 'custom',
}

export interface UserPreferences<Category> {
accept_type: AcceptType;
accepted_categories: Array<Category>;
rejected_categories: Array<Category>;
}

/**
* Instance of the underlying CookieConsent component.
* For available API, see https://github.com/orestbida/cookieconsent#apis--configuration-parameters
Expand All @@ -21,18 +34,6 @@ export namespace VanillaCookieConsent {
getUserPreferences: () => UserPreferences<Category>;
};

export interface UserPreferences<Category> {
accept_type: AcceptType;
accepted_categories: Array<Category>;
rejected_categories: Array<Category>;
}

export enum AcceptType {
ALL = 'all',
NECESSARY = 'necessary',
CUSTOM = 'custom',
}

export enum PrimaryButtonRole {
ACCEPT_ALL = 'accept_all',
ACCEPT_SELECTED = 'accept_selected',
Expand Down Expand Up @@ -171,3 +172,4 @@ export namespace VanillaCookieConsent {
languages?: Record<string, Languages>;
}
}
/* eslint-enable no-unused-vars */

0 comments on commit 05d7ce6

Please sign in to comment.