Created
December 27, 2024 04:01
-
-
Save minenwerfer/3f355b7e5f3c32514244ce64ffbe2724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FromInput<T, Acc = never> = T extends `${string}{${infer K}}${infer Rest}` | |
? FromInput<Rest, Acc | K> | |
: Acc | |
declare const t: <const TInput>(input: TInput, options: { | |
replace: Record<FromInput<TInput>, unknown> | |
}) => string | |
enum Messages { | |
InitialMessage = 'hello, {name}! you have {n} messages', | |
} | |
t(Messages.InitialMessage, { | |
replace: { | |
name: 'User', | |
n: 0, | |
}, | |
}) | |
t(Messages.InitialMessage, { | |
replace: { | |
// @ts-expect-error the line below will fail as 'nxame' does not exist on 'name' | 'n' | |
nxame: 'User', | |
n: 0, | |
}, | |
}) | |
export {} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment