Skip to content

Commit

Permalink
[ts] add back generics
Browse files Browse the repository at this point in the history
  • Loading branch information
enzoaicardi committed Jul 23, 2024
1 parent 51dcfc6 commit 1a2ff8d
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,29 @@ declare module "vifjs" {
* @see {@link https://github.com/vifjs/vif/tree/main/wiki/methods/define.md}
*/
type VifArguments = {
props?: Object;
props?: VifArgumentsProps;
html?: (string: TemplateStringsArray) => string;
css?: (string: TemplateStringsArray) => string;
};

interface VifSignal {
(updatedValue?: any): [updatedValue: any];
value: [updatedValue: any];
interface VifArgumentsProps {
[key: string]: any;
}

interface VifSignal<Type> {
(updatedValue?: Type): [updatedValue: Type];
value: [updatedValue: Type];
}

type VifReactive = Function;

interface VifTranslations extends VifSignal {
type VifTranslationsObject = {
[country: string]: {
[province: string]: () => Promise<Object>;
};
};

interface VifTranslations<Type> extends VifSignal<Type> {
/**
* Execute a callback after translations have been loaded
* @param {Function} callback Function called after translations have been loaded
Expand All @@ -78,7 +88,7 @@ declare module "vifjs" {
* @returns {VifSignal} A signal that can be used to trigger reactives functions
* @see {@link https://github.com/vifjs/vif/tree/main/wiki/methods/signal.md}
*/
function useSignal(initialValue: any): VifSignal;
function useSignal<Type>(initialValue: Type): VifSignal<Type>;

/**
* Function used to create a reactive function played every time the value of a signal inside changes
Expand Down Expand Up @@ -110,9 +120,5 @@ declare module "vifjs" {
* @returns {VifTranslations} Signal containing all the translations for the current locale
* @see {@link https://github.com/vifjs/vif/tree/main/wiki/methods/i18n.md}
*/
function useI18n(locales: {
[country: string]: {
[province: string]: () => Promise<Object>;
};
}): VifTranslations;
function useI18n(locales: VifTranslationsObject): VifTranslations<any>;
}

0 comments on commit 1a2ff8d

Please sign in to comment.