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, Node,
ObjectExpression, ObjectExpression,
ImportDeclaration, ImportDeclaration,
@ -8,13 +8,13 @@ import {
Literal, Literal,
} from 'estree'; } from 'estree';
import { walk } from 'estree-walker'; 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 { parse } from 'svelte/compiler';
import dlv from 'dlv'; import dlv from 'dlv';
import { deepSet } from './includes/deepSet'; import { deepSet } from './includes/deepSet';
import { getObjFromExpression } from './includes/getObjFromExpression'; import { getObjFromExpression } from './includes/getObjFromExpression';
import { Message } from './types'; import type { Message } from './types';
const LIB_NAME = 'svelte-i18n'; const LIB_NAME = 'svelte-i18n';
const DEFINE_MESSAGES_METHOD_NAME = 'defineMessages'; 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) { export function getObjFromExpression(exprNode: ObjectExpression) {
return exprNode.properties.reduce<Message>((acc, prop: Property) => { 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'; import { $locale } from './stores/locale';
interface Formats { interface Formats {

View File

@ -1,6 +1,6 @@
import IntlMessageFormat from 'intl-messageformat'; import IntlMessageFormat from 'intl-messageformat';
import { MemoizedIntlFormatter } from '../types'; import type { MemoizedIntlFormatter } from '../types';
import { getCurrentLocale } from '../stores/locale'; import { getCurrentLocale } from '../stores/locale';
import { getOptions } from '../configs'; import { getOptions } from '../configs';
import { monadicMemoize } from './memoize'; import { monadicMemoize } from './memoize';

View File

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

View File

@ -1,4 +1,4 @@
import { MessageObject } from './types'; import type { MessageObject } from './types';
import { getCurrentLocale, $locale } from './stores/locale'; import { getCurrentLocale, $locale } from './stores/locale';
import { getOptions, init } from './configs'; import { getOptions, init } from './configs';
import { flush, registerLocaleLoader } from './includes/loaderQueue'; import { flush, registerLocaleLoader } from './includes/loaderQueue';

View File

@ -2,7 +2,7 @@ import { writable, derived } from 'svelte/store';
import deepmerge from 'deepmerge'; import deepmerge from 'deepmerge';
import dlv from 'dlv'; import dlv from 'dlv';
import { LocaleDictionary, LocalesDictionary } from '../types/index'; import type { LocaleDictionary, LocalesDictionary } from '../types/index';
import { getFallbackOf } from './locale'; import { getFallbackOf } from './locale';
let dictionary: LocalesDictionary; let dictionary: LocalesDictionary;

View File

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

View File

@ -49,7 +49,7 @@ export type NumberFormatter = (
options?: IntlFormatterOptions<Intl.NumberFormatOptions>, options?: IntlFormatterOptions<Intl.NumberFormatOptions>,
) => string; ) => 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 & { type IntlFormatterOptions<T> = T & {
format?: string; format?: string;

View File

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

759
yarn.lock

File diff suppressed because it is too large Load Diff