Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change MessageFormatter's function signature #109

Closed
dkzlv opened this issue Nov 23, 2020 · 2 comments
Closed

Change MessageFormatter's function signature #109

dkzlv opened this issue Nov 23, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dkzlv
Copy link

dkzlv commented Nov 23, 2020

Is your feature request related to a problem? Please describe.
Currently there's no simple way to use the embedded $format (_) in TypeScript, since it returns a function, that returns string | unknown. You cannot pass values as props with string type, you cannot use it in most of the HTML attributes (like placeholder), etc.

Describe the solution you'd like
Change signature for MessageFormatter's function to string instead of string | unknown. Or any if unknown is there for a very valid reason (not sure, the documentation here states that it always returns string).

Describe alternatives you've considered
I've wrapped it myself in my project.

import { _ as $format } from 'svelte-i18n';
import { MessageObject } from 'svelte-i18n/types/runtime/types';
import { Readable } from 'svelte/store';

export const _ = $format as Readable<
  (id: string | MessageObject, options?: MessageObject) => string
>;

Not very clean or beautiful, tbh.

How important is this feature to you?
Quite!

@kaisermann kaisermann self-assigned this Nov 23, 2020
@kaisermann kaisermann added the bug Something isn't working label Nov 23, 2020
@kaisermann
Copy link
Owner

Hey 👋 fixed in 3.2.7! Since 3.2.0, the format method can also return an object or array, but setting it to return unknown was indeed a mistake.

@dkzlv
Copy link
Author

dkzlv commented Nov 23, 2020

@kaisermann Holy shit you're fast. Thanks! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants