Suppress eslint explicit any warnings required for the advanced type trickery to work.
At the call site the types are correct, it is just the type signatures that require any.
This commit is contained in:
parent
c1647ab498
commit
ad515c5be9
frontend/src
@ -6,8 +6,8 @@ type MessageType = typeof messages;
|
||||
type MessageKeys = keyof MessageType;
|
||||
|
||||
type MessageParams<T extends MessageKeys> = MessageType[T]["en"] extends (
|
||||
...args: any
|
||||
) => any
|
||||
...args: any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
) => any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
? Parameters<MessageType[T]["en"]>
|
||||
: [];
|
||||
|
||||
@ -19,7 +19,7 @@ export function useI18n() {
|
||||
...args: MessageParams<T>
|
||||
): string {
|
||||
const message = messages[key][lang] ?? messages[key]["en"];
|
||||
// @ts-ignore
|
||||
// @ts-expect-error see https://stackoverflow.com/a/75086839
|
||||
return typeof message === "function" ? message(...args) : message;
|
||||
};
|
||||
}
|
||||
|
@ -19,5 +19,5 @@ export const messages = {
|
||||
},
|
||||
} as const satisfies Record<
|
||||
string,
|
||||
AllLanguages<string | ((...args: any) => string)>
|
||||
AllLanguages<string> | AllLanguages<(...args: any) => string> // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user