mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 09:59:58 +01:00
Refactor type imports to use type modifier
This commit is contained in:
parent
abbd396128
commit
739d784c16
@ -1,4 +1,4 @@
|
||||
import {
|
||||
import type {
|
||||
Node,
|
||||
ObjectExpression,
|
||||
ImportDeclaration,
|
||||
@ -8,13 +8,13 @@ import {
|
||||
Literal,
|
||||
} from 'estree';
|
||||
import { walk } from 'estree-walker';
|
||||
import { Ast } from 'svelte/types/compiler/interfaces';
|
||||
import type { Ast } from 'svelte/types/compiler/interfaces';
|
||||
import { parse } from 'svelte/compiler';
|
||||
import dlv from 'dlv';
|
||||
|
||||
import { deepSet } from './includes/deepSet';
|
||||
import { getObjFromExpression } from './includes/getObjFromExpression';
|
||||
import { Message } from './types';
|
||||
import type { Message } from './types';
|
||||
|
||||
const LIB_NAME = 'svelte-i18n';
|
||||
const DEFINE_MESSAGES_METHOD_NAME = 'defineMessages';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ObjectExpression, Property, Identifier } from 'estree';
|
||||
import type { ObjectExpression, Property, Identifier } from 'estree';
|
||||
|
||||
import { Message } from '../types';
|
||||
import type { Message } from '../types';
|
||||
|
||||
export function getObjFromExpression(exprNode: ObjectExpression) {
|
||||
return exprNode.properties.reduce<Message>((acc, prop: Property) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ConfigureOptions } from './types';
|
||||
import type { ConfigureOptions } from './types';
|
||||
import { $locale } from './stores/locale';
|
||||
|
||||
interface Formats {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import IntlMessageFormat from 'intl-messageformat';
|
||||
|
||||
import { MemoizedIntlFormatter } from '../types';
|
||||
import type { MemoizedIntlFormatter } from '../types';
|
||||
import { getCurrentLocale } from '../stores/locale';
|
||||
import { getOptions } from '../configs';
|
||||
import { monadicMemoize } from './memoize';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { MessagesLoader } from '../types';
|
||||
import type { MessagesLoader } from '../types';
|
||||
import {
|
||||
hasLocaleDictionary,
|
||||
$dictionary,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { MessageObject } from './types';
|
||||
import type { MessageObject } from './types';
|
||||
import { getCurrentLocale, $locale } from './stores/locale';
|
||||
import { getOptions, init } from './configs';
|
||||
import { flush, registerLocaleLoader } from './includes/loaderQueue';
|
||||
|
@ -2,7 +2,7 @@ import { writable, derived } from 'svelte/store';
|
||||
import deepmerge from 'deepmerge';
|
||||
import dlv from 'dlv';
|
||||
|
||||
import { LocaleDictionary, LocalesDictionary } from '../types/index';
|
||||
import type { LocaleDictionary, LocalesDictionary } from '../types/index';
|
||||
import { getFallbackOf } from './locale';
|
||||
|
||||
let dictionary: LocalesDictionary;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { derived } from 'svelte/store';
|
||||
|
||||
import {
|
||||
import type {
|
||||
MessageFormatter,
|
||||
MessageObject,
|
||||
TimeFormatter,
|
||||
|
@ -49,7 +49,7 @@ export type NumberFormatter = (
|
||||
options?: IntlFormatterOptions<Intl.NumberFormatOptions>,
|
||||
) => string;
|
||||
|
||||
export type JSONGetter = <T extends any>(id: string, locale?: string) => T;
|
||||
export type JSONGetter = <T>(id: string, locale?: string) => T;
|
||||
|
||||
type IntlFormatterOptions<T> = T & {
|
||||
format?: string;
|
||||
|
@ -30,7 +30,7 @@ test('gets a message from the fallback dictionary', () => {
|
||||
expect(lookup('field', 'en-US')).toBe('name');
|
||||
});
|
||||
|
||||
test('gets an array ', () => {
|
||||
test('gets an array', () => {
|
||||
addMessages('en', {
|
||||
careers: [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
import {
|
||||
import type {
|
||||
JSONGetter,
|
||||
MessageFormatter,
|
||||
TimeFormatter,
|
||||
|
Loading…
Reference in New Issue
Block a user