Refactor type imports to use type modifier

This commit is contained in:
Christian Kaisermann 2020-12-03 15:08:34 -03:00
parent abbd396128
commit 739d784c16
12 changed files with 415 additions and 372 deletions

View File

@ -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';

View File

@ -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) => {

View File

@ -1,4 +1,4 @@
import { ConfigureOptions } from './types';
import type { ConfigureOptions } from './types';
import { $locale } from './stores/locale';
interface Formats {

View File

@ -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';

View File

@ -1,4 +1,4 @@
import { MessagesLoader } from '../types';
import type { MessagesLoader } from '../types';
import {
hasLocaleDictionary,
$dictionary,

View File

@ -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';

View File

@ -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;

View File

@ -1,6 +1,6 @@
import { derived } from 'svelte/store';
import {
import type {
MessageFormatter,
MessageObject,
TimeFormatter,

View File

@ -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;

View File

@ -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: [
{

View File

@ -1,6 +1,6 @@
import { get } from 'svelte/store';
import {
import type {
JSONGetter,
MessageFormatter,
TimeFormatter,

759
yarn.lock

File diff suppressed because it is too large Load Diff