Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Nov 14, 2024
1 parent c8eb283 commit ef7192e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
20 changes: 3 additions & 17 deletions packages/use-intl/src/core/ICUArgs.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
import {GetICUArgs} from '@schummar/icu-type-parser';
import {GetICUArgs, GetICUArgsOptions} from '@schummar/icu-type-parser';

type ICUArgs<
Message extends string,
ICUArgument,
ICUNumberArgument,
ICUDateArgument
> =
type ICUArgs<Message extends string, Options extends GetICUArgsOptions> =
// This is important when `t` is returned from a function and there's no
// known `Message` yet. Otherwise, we'd run into an infinite loop.
string extends Message
? {}
: GetICUArgs<
Message,
{
ICUArgument: ICUArgument;
ICUNumberArgument: ICUNumberArgument;
ICUDateArgument: ICUDateArgument;
}
>;
string extends Message ? {} : GetICUArgs<Message, Options>;

export default ICUArgs;
9 changes: 8 additions & 1 deletion packages/use-intl/src/core/createTranslator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ import {Prettify} from './types.tsx';
type ICUArgsWithTags<
MessageString extends string,
TagsFn extends RichTagsFunction | MarkupTagsFunction = never
> = ICUArgs<MessageString, ICUArg, ICUNumber, ICUDate> &
> = ICUArgs<
MessageString,
{
ICUArgument: ICUArg;
ICUNumberArgument: ICUNumber;
ICUDateArgument: ICUDate;
}
> &
([TagsFn] extends [never] ? {} : ICUTags<MessageString, TagsFn>);

type OnlyOptional<T> = Partial<T> extends T ? true : false;
Expand Down

0 comments on commit ef7192e

Please sign in to comment.