Skip to content

Commit

Permalink
fix: 🐛 default $json type to any
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Feb 11, 2021
1 parent 0dec146 commit 41d8e4d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 0 additions & 10 deletions docs/Formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,6 @@ Returns the raw JSON value of the specified `messageId` for the current locale.
</ul>
```

If you're using TypeScript, you can define the returned type as well:

```html
<ul>
{#each $json<Item[]>('list.items') as item}
<li>{item.name}</li>
{/each}
</ul>
```

### Formats

`svelte-i18n` comes with a default set of `number`, `time` and `date` formats:
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/stores/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const formatNumber: NumberFormatter = (n, options) => {
return getNumberFormatter(options).format(n);
};

const getJSON: JSONGetter = <T>(id: string, locale = getCurrentLocale()) => {
const getJSON: JSONGetter = <T = any>(id: string, locale = getCurrentLocale()) => {
return lookup(id, locale) as T;
};

Expand Down

0 comments on commit 41d8e4d

Please sign in to comment.