From 925122c681db794b2d0b4c83da79d13e1b3bfa82 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Thu, 5 Sep 2024 17:16:39 +0900 Subject: [PATCH 1/3] fix: type errors --- .github/workflows/ci.yml | 28 - package.json | 5 +- packages/core-base/src/index.ts | 32 +- packages/core-base/src/runtime.ts | 12 +- packages/core-base/src/translate.ts | 74 +-- packages/core-base/src/types/utils.ts | 141 ++-- packages/core-base/test/context.test-d.ts | 226 +++++++ packages/core-base/test/datetime.test-d.ts | 37 ++ packages/core-base/test/helper.ts | 2 +- packages/core-base/test/number.test-d.ts | 32 + packages/core-base/test/runtime.test-d.ts | 130 ++++ .../core-base/test}/schema.ts | 3 +- packages/core-base/test/translate.test-d.ts | 57 ++ packages/core-base/test/translate.test.ts | 31 +- packages/core-base/test/types.test-d.ts | 325 +++++++++ packages/vue-i18n-core/src/i18n.ts | 62 +- packages/vue-i18n-core/src/utils.ts | 14 +- .../test/components/DatetimeFormat.test.ts | 14 +- .../test/components/NumberFormat.test.ts | 14 +- .../test/components/Translation.test.ts | 26 +- .../test/components/components.test-d.tsx | 19 + .../vue-i18n-core/test/composer.test-d.ts | 382 +++++++++++ packages/vue-i18n-core/test/i18n.test-d.ts | 616 ++++++++++++++++++ packages/vue-i18n-core/test/issues.test.ts | 35 +- packages/vue-i18n-core/test/legacy.test-d.ts | 249 +++++++ packages/vue-i18n-core/test/mixin.test.ts | 12 +- packages/vue-i18n-core/test/schema.ts | 20 + pnpm-lock.yaml | 210 +++--- rollup.config.mjs | 14 +- test-dts/core-base/context.test-d.ts | 212 ------ test-dts/core-base/datetime.test-d.ts | 35 - test-dts/core-base/number.test-d.ts | 30 - test-dts/core-base/runtime.test-d.ts | 86 --- test-dts/core-base/translate.test-d.ts | 43 -- test-dts/index.d.ts | 5 - test-dts/tsconfig.json | 8 - test-dts/vue-i18n/components.test-d.tsx | 19 - test-dts/vue-i18n/composer.test-d.ts | 334 ---------- test-dts/vue-i18n/i18n.test-d.ts | 522 --------------- test-dts/vue-i18n/legacy.test-d.ts | 250 ------- tsconfig.json | 1 - 41 files changed, 2469 insertions(+), 1898 deletions(-) create mode 100644 packages/core-base/test/context.test-d.ts create mode 100644 packages/core-base/test/datetime.test-d.ts create mode 100644 packages/core-base/test/number.test-d.ts rename {test-dts => packages/core-base/test}/schema.ts (80%) create mode 100644 packages/core-base/test/translate.test-d.ts create mode 100644 packages/core-base/test/types.test-d.ts create mode 100644 packages/vue-i18n-core/test/components/components.test-d.tsx create mode 100644 packages/vue-i18n-core/test/composer.test-d.ts create mode 100644 packages/vue-i18n-core/test/i18n.test-d.ts create mode 100644 packages/vue-i18n-core/test/legacy.test-d.ts create mode 100644 packages/vue-i18n-core/test/schema.ts delete mode 100644 test-dts/core-base/context.test-d.ts delete mode 100644 test-dts/core-base/datetime.test-d.ts delete mode 100644 test-dts/core-base/number.test-d.ts delete mode 100644 test-dts/core-base/runtime.test-d.ts delete mode 100644 test-dts/core-base/translate.test-d.ts delete mode 100644 test-dts/index.d.ts delete mode 100644 test-dts/tsconfig.json delete mode 100644 test-dts/vue-i18n/components.test-d.tsx delete mode 100644 test-dts/vue-i18n/composer.test-d.ts delete mode 100644 test-dts/vue-i18n/i18n.test-d.ts delete mode 100644 test-dts/vue-i18n/legacy.test-d.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55d5e3989..d895df888 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,34 +107,6 @@ jobs: run: | pnpm test:cover - test-type: - name: Type checking - strategy: - matrix: - os: [ubuntu-latest] - node: [18] - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout codes - uses: actions/checkout@v4 - - - name: Enable corepack - run: corepack enable - - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install --no-frozen-lockfile - - - name: Run type checking - run: pnpm test:type - test-e2e: name: E2E test diff --git a/package.json b/package.json index 5522f6774..264e500b9 100644 --- a/package.json +++ b/package.json @@ -67,8 +67,7 @@ "test": "run-s lint test:cover test:type check-install test:e2e", "test:cover": "pnpm test:unit --coverage", "test:e2e": "cross-env TZ=UTC vitest run -c ./vitest.e2e.config.ts", - "test:type": "tsc -p ./test-dts/tsconfig.json", - "test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts" + "test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts --typecheck" }, "devDependencies": { "@eslint/js": "^9.9.1", @@ -143,7 +142,7 @@ "trash-cli": "^6.0.0", "tslib": "^2.6.2", "tsx": "^4.11.2", - "typescript": "^5.3.3", + "typescript": "^5.5.3", "typescript-eslint": "^8.4.0", "vitepress": "1.3.4", "vitest": "^2.0.4", diff --git a/packages/core-base/src/index.ts b/packages/core-base/src/index.ts index 7e9d8205a..bf4a71ec1 100644 --- a/packages/core-base/src/index.ts +++ b/packages/core-base/src/index.ts @@ -3,30 +3,30 @@ import { initFeatureFlags } from './misc' export { CompileError, CompileErrorCodes, - ResourceNode, - createCompileError + createCompileError, + ResourceNode } from '@intlify/message-compiler' -export * from './resolver' -export * from './runtime' -export * from './context' -export * from './fallbacker' export * from './compilation' -export * from './translate' +export * from './context' export * from './datetime' -export * from './number' -export { - getWarnMessage, - CoreWarnCodes, - CORE_WARN_CODES_EXTEND_POINT -} from './warnings' +export * from './devtools' export { + CORE_ERROR_CODES_EXTEND_POINT, CoreError, CoreErrorCodes, - createCoreError, - CORE_ERROR_CODES_EXTEND_POINT + createCoreError } from './errors' +export * from './fallbacker' +export * from './number' +export * from './resolver' +export * from './runtime' +export * from './translate' export * from './types' -export * from './devtools' +export { + CORE_WARN_CODES_EXTEND_POINT, + CoreWarnCodes, + getWarnMessage +} from './warnings' if (__ESM_BUNDLER__ && !__TEST__) { initFeatureFlags() diff --git a/packages/core-base/src/runtime.ts b/packages/core-base/src/runtime.ts index 17bb6fa51..1baaeab65 100644 --- a/packages/core-base/src/runtime.ts +++ b/packages/core-base/src/runtime.ts @@ -10,17 +10,9 @@ import { join, toDisplayString } from '@intlify/shared' -import { Path } from './resolver' -import { IsNever } from './types' -type ExtractToStringKey = Extract -type ExtractToStringFunction = T[ExtractToStringKey] -// prettier-ignore -type StringConvertable = ExtractToStringKey extends never - ? unknown - : ExtractToStringFunction extends (...args: any) => string // eslint-disable-line @typescript-eslint/no-explicit-any - ? T - : unknown +import type { Path } from './resolver' +import type { IsNever, StringConvertable } from './types' /** * diff --git a/packages/core-base/src/translate.ts b/packages/core-base/src/translate.ts index 517cd2eef..d5eb6a56f 100644 --- a/packages/core-base/src/translate.ts +++ b/packages/core-base/src/translate.ts @@ -1,65 +1,65 @@ import { - isString, - isNumber, - isFunction, - isBoolean, - isArray, - isPlainObject, - isEmptyObject, - generateFormatCacheKey, - generateCodeFrame, + assign, escapeHtml, + generateCodeFrame, + generateFormatCacheKey, inBrowser, - warn, + isArray, + isBoolean, + isEmptyObject, + isFunction, + isNumber, + isObject, + isPlainObject, + isString, mark, measure, - assign, - isObject + warn } from '@intlify/shared' import { isMessageAST } from './compilation' -import { createMessageContext } from './runtime' import { - isTranslateFallbackWarn, + CoreContext, + getAdditionalMeta, + handleMissing, isAlmostSameLocale, isImplicitFallback, - handleMissing, - NOT_REOSLVED, - getAdditionalMeta, - CoreContext + isTranslateFallbackWarn, + NOT_REOSLVED } from './context' -import { CoreWarnCodes, getWarnMessage } from './warnings' -import { CoreErrorCodes, createCoreError } from './errors' import { translateDevTools } from './devtools' +import { CoreErrorCodes, createCoreError } from './errors' import { getLocale } from './fallbacker' +import { createMessageContext } from './runtime' +import { CoreWarnCodes, getWarnMessage } from './warnings' -import type { CompileError, ResourceNode } from '@intlify/message-compiler' import type { AdditionalPayloads } from '@intlify/devtools-types' -import type { Path, PathValue } from './resolver' -import type { - Locale, - FallbackLocale, - NamedValue, - MessageFunction, - MessageFunctionReturn, - MessageFunctionInternal, - MessageContextOptions, - MessageContext -} from './runtime' +import type { CompileError, ResourceNode } from '@intlify/message-compiler' import type { + CoreInternalContext, + DefineCoreLocaleMessage, LocaleMessages, LocaleMessageValue, - CoreInternalContext, MessageCompilerContext } from './context' import type { LocaleOptions } from './fallbacker' +import type { Path, PathValue } from './resolver' +import type { + FallbackLocale, + Locale, + MessageContext, + MessageContextOptions, + MessageFunction, + MessageFunctionInternal, + MessageFunctionReturn, + NamedValue +} from './runtime' import type { - PickupKeys, IsEmptyObject, - RemovedIndexResources, + IsNever, + PickupKeys, PickupPaths, - IsNever + RemovedIndexResources } from './types' -import type { DefineCoreLocaleMessage } from './context' const NOOP_MESSAGE_FUNCTION = () => '' diff --git a/packages/core-base/src/types/utils.ts b/packages/core-base/src/types/utils.ts index 126773670..1143cca9d 100644 --- a/packages/core-base/src/types/utils.ts +++ b/packages/core-base/src/types/utils.ts @@ -1,14 +1,32 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { LocaleMessage } from '../context' -import type { DateTimeFormat, NumberFormat } from './intl' +import type { LocaleMessage } from '../context'; +import type { DateTimeFormat, NumberFormat } from './intl'; + +export type IsNever = [T] extends [never] ? true : false export type IsUnion = T extends B ? [B] extends [T] - ? false - : true + ? false + : true : never +export type IsTuple = IsNever extends true + ? false + : T extends readonly any[] + ? number extends T['length'] + ? false + : true + : false; + +export type IsRecord = IsTuple extends true + ? false + : [T] extends [Record] ? true : false + +export type IsObject = IsTuple extends true + ? false + : [T] extends [object] ? true : false + // prettier-ignore export type UnionToIntersection = (U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I @@ -30,21 +48,21 @@ export type LocaleRecord = { export type First = T[0] -export declare type JsonPaths = Key extends string ? +export declare type JsonPaths = Key extends string ? T[Key] extends Record ? - `${Key}.${JsonPaths}` + `${Key}.${JsonPaths}` : `${Key}` -: never; + : never; export declare type TranslationsPaths = K extends string ? JsonPaths : never; export type __ResourcePath = Key extends string ? T[Key] extends Record - ? - | `${Key}.${__ResourcePath> & - string}` - | `${Key}.${Exclude & string}` - : never + ? + | `${Key}.${__ResourcePath> & + string}` + | `${Key}.${Exclude & string}` + : never : never export type _ResourcePath = __ResourcePath | keyof T export type ResourcePath = _ResourcePath extends string | keyof T @@ -56,10 +74,10 @@ export type ResourceValue< P extends ResourcePath > = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T - ? Rest extends ResourcePath - ? ResourceValue - : never - : never + ? Rest extends ResourcePath + ? ResourceValue + : never + : never : P extends keyof T ? T[P] : never @@ -78,8 +96,8 @@ export type PickupPaths = ResourcePath type __ResourceFormatPath = Key extends string ? T[Key] extends Record - ? | `${Key}` - : never + ? | `${Key}` + : never : never type _ResourceFormatPath = __ResourceFormatPath | keyof T export type ResourceFormatPath = _ResourceFormatPath extends string | keyof T @@ -87,8 +105,8 @@ export type ResourceFormatPath = _ResourceFormatPath extends string | keyo : keyof T export type PickupFormatKeys< - T extends Record, - K = keyof T + T extends Record, + K = keyof T > = K extends string ? ResourceFormatPath : never export type PickupFormatPathKeys = ResourceFormatPath @@ -99,60 +117,85 @@ export type FallbackLocales = | Locales | Array | { - [locale in string]: Array>> - } + [locale in string]: Array>> + } | false // prettier-ignore type LocaleParamsType = T extends IsUnion ? T : T extends string - ? T - : R + ? T + : R // prettier-ignore export type SchemaParams = T extends readonly any[] ? { message: First, datetime: DateTimeFormat, number: NumberFormat } : T extends { message?: infer M, datetime?: infer D, number?: infer N } - ? { - message: M extends LocaleMessage ? M : LocaleMessage, - datetime: D extends DateTimeFormat ? D : DateTimeFormat, - number: N extends NumberFormat ? N : NumberFormat - } - : { - message: LocaleMessage, - datetime: DateTimeFormat, - number: NumberFormat - } + ? { + message: M extends LocaleMessage ? M : LocaleMessage, + datetime: D extends DateTimeFormat ? D : DateTimeFormat, + number: N extends NumberFormat ? N : NumberFormat + } + : { + message: LocaleMessage, + datetime: DateTimeFormat, + number: NumberFormat + } // prettier-ignore export type LocaleParams = T extends IsUnion ? { messages: T, datetimeFormats: T, numberFormats: T } : T extends { messages?: infer M, datetimeFormats?: infer D, numberFormats?: infer N } - ? { - messages: LocaleParamsType, - datetimeFormats: LocaleParamsType, - numberFormats: LocaleParamsType - } - : T extends string - ? { messages: T, datetimeFormats: T, numberFormats: T } - : { messages: Default, datetimeFormats: Default, numberFormats: Default } + ? { + messages: LocaleParamsType, + datetimeFormats: LocaleParamsType, + numberFormats: LocaleParamsType + } + : T extends string + ? { messages: T, datetimeFormats: T, numberFormats: T } + : { messages: Default, datetimeFormats: Default, numberFormats: Default } // prettier-ignore export type RemoveIndexSignature = { [K in keyof T as string extends K - ? never - : number extends K - ? never - : K + ? never + : number extends K + ? never + : K ]: T[K] } -export type IsNever = [T] extends [never] ? true : false -export type IsEmptyObject = IsNever extends true ? true : false +declare const emptyObjectSymbol: unique symbol +export type EmptyObject = { [emptyObjectSymbol]?: never }; +export type IsEmptyObject = T extends { [emptyObjectSymbol]?: never } ? true : false; export type RemovedIndexResources = RemoveIndexSignature<{ [K in keyof T]: T[K] }> -/* eslint-enable @typescript-eslint/no-explicit-any */ \ No newline at end of file +export type ExtractToStringKey = Extract +// export type ExtractToStringFunction = T[ExtractToStringKey] + +/** + * weather the type `T` is able to convert to string with `toString` method + */ +export type StringConvertable> = IsNever extends true + ? T extends boolean + ? T + : T extends Function + ? T + : IsObject extends true + ? T + : unknown + : T +// : ExtractToStringFunction extends (...args: any) => string +// ? T +// : unknown +// export type StringConvertable = IsNever> extends true +// ? unknown +// : ExtractToStringFunction extends (...args: any) => string +// ? T +// : unknown + +/* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/packages/core-base/test/context.test-d.ts b/packages/core-base/test/context.test-d.ts new file mode 100644 index 000000000..571e2000a --- /dev/null +++ b/packages/core-base/test/context.test-d.ts @@ -0,0 +1,226 @@ +import { + createCoreContext, + DateTimeFormat, + Locale, + LocaleDetector, + NumberFormat, + PickupFallbackLocales +} from '../src' + +import type { MyDatetimeScehma, MyNumberSchema, ResourceSchema } from './schema' + +// loose options +const looseOptions = { + locale: 'en', + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + } + }, + ja: { + bar: 'foo', + nest: { + bar: 'bar' + } + } + }, + datetimeFormats: { + 'en-US': { + short: {} + } + }, + numberFormats: { + 'ja-JP': { + currency: {} + } + } +} + +// strict options +const strictOptions = { + locale: 'en', + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }, + ja: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error2'] + } + } +} + +test('loose context', () => { + const looseCtx = createCoreContext(looseOptions) + + expectTypeOf(looseCtx.locale).toEqualTypeOf<'en' | 'ja' | 'en-US' | 'ja-JP'>() + expectTypeOf(looseCtx.fallbackLocale).toEqualTypeOf< + | 'en' + | 'ja' + | 'en-US' + | 'ja-JP' + | ('en' | 'ja' | 'en-US' | 'ja-JP')[] + | { + [x in string]: PickupFallbackLocales< + ['en' | 'ja' | 'en-US' | 'ja-JP'] + >[] + } + | false + >() + expectTypeOf(looseCtx.messages).toEqualTypeOf<{ + en: { + foo: string + nest: { + bar: string + } + } + ja: { + bar: string + nest: { + bar: string + } + } + }>() + expectTypeOf(looseCtx.datetimeFormats).toEqualTypeOf<{ + 'en-US': { short: {} } + }>() + expectTypeOf(looseCtx.numberFormats).toEqualTypeOf<{ + 'ja-JP': { currency: {} } + }>() +}) + +test('strict context', () => { + const strictCtx = createCoreContext<[ResourceSchema], 'en' | 'ja'>( + strictOptions + ) + + expectTypeOf(strictCtx.locale).toEqualTypeOf<'en' | 'ja'>() + expectTypeOf(strictCtx.fallbackLocale).toEqualTypeOf< + | 'en' + | 'ja' + | ('en' | 'ja')[] + | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } + | false + >() + expectTypeOf(strictCtx.messages).toEqualTypeOf<{ + en: ResourceSchema + ja: ResourceSchema + }>() + expectTypeOf(strictCtx.datetimeFormats).toEqualTypeOf<{ + en: DateTimeFormat + ja: DateTimeFormat + }>() + expectTypeOf(strictCtx.numberFormats).toEqualTypeOf<{ + en: NumberFormat + ja: NumberFormat + }>() +}) + +test('strict context with direct options', () => { + // check strict context with direct options + const strictDirectCtx = createCoreContext< + { + message: ResourceSchema + datetime: MyDatetimeScehma + number: MyNumberSchema + }, + { messages: 'en'; datetimeFormats: 'ja-JP' | 'zh'; numberFormats: 'ca' } + >({ + messages: { + en: { + foo: '', + nest: { + bar: '' + }, + errors: [''] + } + }, + datetimeFormats: { + zh: { + short: { + hour: 'numeric' + } + }, + 'ja-JP': { + short: { + hour: 'numeric' + } + } + }, + numberFormats: { + ca: { + currency: { + style: 'currency', + currencyDisplay: 'symbol' + } + } + } + }) + + expectTypeOf(strictDirectCtx.locale).toEqualTypeOf< + 'en' | 'zh' | 'ca' | 'ja-JP' + >() + expectTypeOf(strictDirectCtx.fallbackLocale).toEqualTypeOf< + | 'en' + | 'zh' + | 'ca' + | 'ja-JP' + | ('en' | 'zh' | 'ca' | 'ja-JP')[] + | { [x in string]: PickupFallbackLocales<['en' | 'zh' | 'ca' | 'ja-JP']>[] } + | false + >() + expectTypeOf(strictDirectCtx.messages).toEqualTypeOf<{ en: ResourceSchema }>() + expectTypeOf(strictDirectCtx.datetimeFormats).toEqualTypeOf<{ + zh: { short: { hour: 'numeric' } } + 'ja-JP': { short: { hour: 'numeric' } } + }>() + expectTypeOf(strictDirectCtx.numberFormats).toEqualTypeOf<{ + ca: { + currency: { + style: 'currency' + currencyDisplay: 'symbol' + } + } + }>() + + const nullCtx1 = createCoreContext({}) + expectTypeOf(nullCtx1.locale).toEqualTypeOf() + nullCtx1.locale = 'ja' + nullCtx1.locale = () => 'ja' + expectTypeOf(nullCtx1.fallbackLocale).toEqualTypeOf< + | string + | string[] + | { [x in string]: PickupFallbackLocales<[string]>[] } + | false + >() + nullCtx1.fallbackLocale = 'en' + + const nullCtx2 = createCoreContext({}) + const locale = nullCtx2.locale + + function detector1(arg: Locale): Locale { + return arg + } + const detector: LocaleDetector = + typeof locale === 'function' + ? detector1.bind(null, 'foo') + : typeof locale === 'string' + ? () => locale + : (arg: Locale) => arg + expectTypeOf(detector) +}) diff --git a/packages/core-base/test/datetime.test-d.ts b/packages/core-base/test/datetime.test-d.ts new file mode 100644 index 000000000..60f0ac817 --- /dev/null +++ b/packages/core-base/test/datetime.test-d.ts @@ -0,0 +1,37 @@ +import { createCoreContext, datetime } from '../src' + +test('datetime type check', () => { + const ctx = createCoreContext({ + locale: 'en-US', + datetimeFormats: { + 'en-US': { + short: { + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + timeZone: 'America/New_York' + } + } + } + }) + + const dt = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)) + + expectTypeOf(datetime(ctx, dt)).toEqualTypeOf< + string | number | Intl.DateTimeFormatPart[] + >() + expectTypeOf( + datetime(ctx, dt, { locale: 'en-US', key: 'short' }) + ).toEqualTypeOf() + expectTypeOf(datetime(ctx, dt, { key: 'short' }, 'en-US')).toEqualTypeOf< + string | number | Intl.DateTimeFormatPart[] + >() + expectTypeOf( + datetime(ctx, dt, { key: 'short' }, { hourCycle: 'h24' }) + ).toEqualTypeOf() + expectTypeOf( + datetime(ctx, dt, { key: 'short' }, 'en-US', { hourCycle: 'h24' }) + ).toEqualTypeOf() +}) diff --git a/packages/core-base/test/helper.ts b/packages/core-base/test/helper.ts index 8acc10ef9..4f27da54a 100644 --- a/packages/core-base/test/helper.ts +++ b/packages/core-base/test/helper.ts @@ -1,5 +1,5 @@ // eumlate VNode interface on intlify -// ref: github.com/vuejs/core/blob/2f07e3460bf51bc1b083f3d03b3d192e042d2d75/packages/runtime-core/src/vnode.ts#L131-L217 +// ref: https://github.com/vuejs/core/blob/2f07e3460bf51bc1b083f3d03b3d192e042d2d75/packages/runtime-core/src/vnode.ts#L131-L217 type VNodeChildAtom = | VNode diff --git a/packages/core-base/test/number.test-d.ts b/packages/core-base/test/number.test-d.ts new file mode 100644 index 000000000..d346d1db0 --- /dev/null +++ b/packages/core-base/test/number.test-d.ts @@ -0,0 +1,32 @@ +import { createCoreContext, number } from '../src' + +test('number type check', () => { + const ctx = createCoreContext({ + locale: 'en-US', + numberFormats: { + 'en-US': { + currency: { + style: 'currency', + currency: 'USD', + currencyDisplay: 'symbol' + } + } + } + }) + + expectTypeOf(number(ctx, 10100)).toEqualTypeOf< + string | number | Intl.NumberFormatPart[] + >() + expectTypeOf( + number(ctx, 10100, { locale: 'en-US', key: 'currency' }) + ).toEqualTypeOf() + expectTypeOf(number(ctx, 10100, { key: 'currency' }, 'en-US')).toEqualTypeOf< + string | number | Intl.NumberFormatPart[] + >() + expectTypeOf( + number(ctx, 10100, { locale: 'en-US', key: 'currency' }, { unit: '' }) + ).toEqualTypeOf() + expectTypeOf( + number(ctx, 10100, { key: 'currency' }, 'en-US', { unit: '' }) + ).toEqualTypeOf() +}) diff --git a/packages/core-base/test/runtime.test-d.ts b/packages/core-base/test/runtime.test-d.ts index e69de29bb..f0d73285d 100644 --- a/packages/core-base/test/runtime.test-d.ts +++ b/packages/core-base/test/runtime.test-d.ts @@ -0,0 +1,130 @@ +import { MessageType } from '../src/runtime' + +/** + * Message Type + */ + +type HaveToStringTypeAlias = { + toString: (arg1: string, arg2: boolean) => string +} +class HaveToStringClass { + toString(arg1: number, arg2: Date): string { + return arg1.toString() + arg2.toString() + } +} +class NotHaveToStringClass {} +enum NumberEnum { + One, + Two +} + +test('string', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('number', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('boolean', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('Date', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('array', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('function', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('symbol', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('object', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('record', () => { + expectTypeOf>>().toEqualTypeOf< + Record + >() +}) + +test('tuple', () => { + expectTypeOf>().toEqualTypeOf< + [number, string] + >() +}) + +test('undefined', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('null', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('string literal', () => { + // NOTE: ? + expectTypeOf>().toEqualTypeOf() +}) + +test('number literal', () => { + expectTypeOf>().toEqualTypeOf<1>() +}) + +test('boolean literal', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('bingint literal', () => { + expectTypeOf< + MessageType<9007199254740992n> + >().toEqualTypeOf<9007199254740992n>() +}) + +test('object literal', () => { + expectTypeOf>().toEqualTypeOf<{ + text: string + }>() +}) + +test('array (tuple) literal', () => { + expectTypeOf>().toEqualTypeOf<[1, 2]>() +}) + +test('function literal', () => { + expectTypeOf ''>>().toEqualTypeOf<() => ''>() +}) + +test('empty object', () => { + expectTypeOf>().toEqualTypeOf<{}>() +}) + +test('class', () => { + expectTypeOf< + MessageType + >().toEqualTypeOf() + expectTypeOf< + MessageType + >().toEqualTypeOf() + expectTypeOf< + MessageType + >().toEqualTypeOf() +}) + +test('enum', () => { + expectTypeOf>().toEqualTypeOf() +}) + +test('enum value', () => { + expectTypeOf>().toEqualTypeOf() +}) + +/* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/test-dts/schema.ts b/packages/core-base/test/schema.ts similarity index 80% rename from test-dts/schema.ts rename to packages/core-base/test/schema.ts index 7a1d83cd8..bd077eb1b 100644 --- a/test-dts/schema.ts +++ b/packages/core-base/test/schema.ts @@ -14,6 +14,7 @@ export type MyDatetimeScehma = { export type MyNumberSchema = { currency: { - style: 'symbol' + style: 'currency' + currencyDisplay: 'symbol' } } diff --git a/packages/core-base/test/translate.test-d.ts b/packages/core-base/test/translate.test-d.ts new file mode 100644 index 000000000..8e219d4ed --- /dev/null +++ b/packages/core-base/test/translate.test-d.ts @@ -0,0 +1,57 @@ +import { createCoreContext, translate } from '../src' + +test('translate type check', () => { + const ctx = createCoreContext({ + locale: 'en', + messages: { + en: { + hello: 'hello world!', + nest: { + world: 'hello nest world!' + } + } + } + }) + + expectTypeOf(translate(ctx, 'hello')).toEqualTypeOf() + expectTypeOf(translate(ctx, 'hello', 1)).toEqualTypeOf() + expectTypeOf( + translate(ctx, 'hello', 1, { locale: 'en', missingWarn: true }) + ).toEqualTypeOf() + expectTypeOf(translate(ctx, 'hello', 'default msg')).toEqualTypeOf< + string | number + >() + expectTypeOf( + translate(ctx, 'hello', 'default msg', { locale: 'en', plural: 2 }) + ).toEqualTypeOf() + expectTypeOf(translate(ctx, 'hello', ['list'])).toEqualTypeOf< + string | number + >() + expectTypeOf(translate(ctx, 'hello', ['list'], 1)).toEqualTypeOf< + string | number + >() + expectTypeOf(translate(ctx, 'hello', ['list'], 'default msg')).toEqualTypeOf< + string | number + >() + expectTypeOf( + translate(ctx, 'hello', ['list'], { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf(translate(ctx, 'hello', { name: 'dio' })).toEqualTypeOf< + string | number + >() + expectTypeOf(translate(ctx, 'hello', { name: 'dio' }, 1)).toEqualTypeOf< + string | number + >() + expectTypeOf( + translate(ctx, 'hello', { name: 'dio' }, 'default msg') + ).toEqualTypeOf() + expectTypeOf( + translate( + ctx, + 'hello', + { name: 'dio' }, + { locale: 'en', resolvedMessage: true } + ) + ).toEqualTypeOf() + expectTypeOf(translate(ctx, 'nest.world')).toEqualTypeOf() +}) diff --git a/packages/core-base/test/translate.test.ts b/packages/core-base/test/translate.test.ts index b62cc60eb..f81c9ba36 100644 --- a/packages/core-base/test/translate.test.ts +++ b/packages/core-base/test/translate.test.ts @@ -12,23 +12,28 @@ vi.mock('@intlify/shared', async () => { } }) -import { createCoreContext as context, NOT_REOSLVED } from '../src/context' -import { translate } from '../src/translate' -import { CoreErrorCodes, errorMessages } from '../src/errors' +import { compile } from '../src/compilation' import { + createCoreContext as context, + NOT_REOSLVED, + registerLocaleFallbacker, registerMessageCompiler, - registerMessageResolver, - registerLocaleFallbacker + registerMessageResolver } from '../src/context' -import { compile } from '../src/compilation' +import { CoreErrorCodes, errorMessages } from '../src/errors' import { fallbackWithLocaleChain } from '../src/fallbacker' import { resolveValue } from '../src/resolver' +import { translate } from '../src/translate' import { createTextNode } from './helper' -import type { MessageContext, MessageFunctionReturn } from '../src/runtime' -import type { VNode } from './helper' -import type { MessageType, MessageProcessor } from '../src/runtime' +import type { + MessageContext, + MessageFunctionReturn, + MessageProcessor, + MessageType +} from '../src/runtime' import type { PickupKeys } from '../src/types/utils' +import type { VNode } from './helper' beforeEach(() => { registerMessageCompiler(compile) @@ -878,6 +883,7 @@ describe('processor', () => { }) ctx.processor = processor expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'hi' @@ -894,6 +900,7 @@ describe('processor', () => { }) ctx.processor = processor expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'hi', @@ -915,6 +922,7 @@ describe('processor', () => { }) ctx.processor = processor expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'hi', @@ -939,6 +947,7 @@ describe('processor', () => { }) ctx.processor = processor expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'hi' @@ -959,6 +968,7 @@ describe('processor', () => { }) ctx.processor = processor expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'apple', @@ -966,6 +976,7 @@ describe('processor', () => { ) ).toEqual([{ __v_isVNode: true, children: 'no apples' }]) expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'apple', @@ -973,6 +984,7 @@ describe('processor', () => { ) ).toEqual([{ __v_isVNode: true, children: 'one apple' }]) expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'apple', @@ -984,6 +996,7 @@ describe('processor', () => { undefined ]) expect( + // @ts-expect-error -- FIXME translate, VNode>( ctx, 'apple', diff --git a/packages/core-base/test/types.test-d.ts b/packages/core-base/test/types.test-d.ts new file mode 100644 index 000000000..bb680f697 --- /dev/null +++ b/packages/core-base/test/types.test-d.ts @@ -0,0 +1,325 @@ +import type { LocaleMessage } from '../src/context' +import type { DateTimeFormat, NumberFormat } from '../src/types/intl' +import type { + ExtractToStringKey, + IsEmptyObject, + LocaleParams, + RemovedIndexResources, + RemoveIndexSignature, + SchemaParams, + StringConvertable +} from '../src/types/utils' + +describe('IsEmptyObject', () => { + test('empty object', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('object', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('object type', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('record type', () => { + expectTypeOf>>().toEqualTypeOf() + }) +}) + +describe('RemoveIndexSignature', () => { + test('interface', () => { + interface Foo { + foo: string + [index: number]: string + } + expectTypeOf>().toEqualTypeOf<{ foo: string }>() + }) + + test('object', () => { + expectTypeOf>().toEqualTypeOf<{ + foo: string + }>() + }) +}) + +describe('RemovedIndexResources', () => { + test('resource', () => { + interface Foo { + foo: string + bar: { + buz: string + } + } + expectTypeOf>().toEqualTypeOf<{ + foo: string + bar: { buz: string } + }>() + }) +}) + +describe('SchemaParams', () => { + test('tuple', () => { + expectTypeOf< + SchemaParams< + [ + { + foo: string + } + ] + > + >().toEqualTypeOf<{ + message: { foo: string } + datetime: DateTimeFormat + number: NumberFormat + }>() + }) + + test('object', () => { + expectTypeOf< + SchemaParams<{ + message: { + foo: string + } + datetime: DateTimeFormat + number: NumberFormat + }> + >().toEqualTypeOf<{ + message: { foo: string } + datetime: DateTimeFormat + number: NumberFormat + }>() + }) + + test('wrong case', () => { + expectTypeOf>().toEqualTypeOf<{ + message: LocaleMessage + datetime: DateTimeFormat + number: NumberFormat + }>() + }) +}) + +describe('LocaleParams', () => { + test('union', () => { + type Local1 = 'en' | 'ja' + expectTypeOf>().toEqualTypeOf< + | { messages: 'en'; datetimeFormats: 'en'; numberFormats: 'en' } + | { messages: 'ja'; datetimeFormats: 'ja'; numberFormats: 'ja' } + >() + }) + + test('object', () => { + expectTypeOf< + LocaleParams<{ + messages: 'ja' + datetimeFormats: 'en' + numberFormats: 'en-US' + }> + >().toEqualTypeOf<{ + messages: 'ja' + datetimeFormats: 'en' + numberFormats: 'en-US' + }>() + }) + + test('string', () => { + expectTypeOf>().toEqualTypeOf<{ + messages: 'ja' + datetimeFormats: 'ja' + numberFormats: 'ja' + }>() + }) + + test('default', () => { + expectTypeOf>().toEqualTypeOf<{ + messages: 'en-US' + datetimeFormats: 'en-US' + numberFormats: 'en-US' + }>() + }) +}) + +describe('ExtractToStringKey', () => { + test('number', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('string', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('symbol', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('bigint', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('array', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('boolean', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('undefined', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('null', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('object', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('record', () => { + expectTypeOf< + ExtractToStringKey> + >().toEqualTypeOf() + }) + + test('tuple', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('function', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('literal number', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('literal bigint', () => { + expectTypeOf< + ExtractToStringKey<9007199254740992n> + >().toEqualTypeOf<'toString'>() + }) + + test('literal string', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + + test('literal boolean', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('literal function', () => { + expectTypeOf {}>>().toEqualTypeOf() + }) + + test('literal object, which does not have toString', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('literal object, which has toString', () => { + expectTypeOf< + ExtractToStringKey<{ toString: () => string }> + >().toEqualTypeOf<'toString'>() + }) + + describe('union', () => { + test('all union has toString', () => { + expectTypeOf>().toEqualTypeOf<'toString'>() + }) + test('some union has toString', () => { + expectTypeOf>().toEqualTypeOf() + }) + }) +}) + +describe('StringConvertable', () => { + test('object has toString', () => { + expectTypeOf< + StringConvertable<{ toString: () => string }> + >().toEqualTypeOf<{ toString: () => string }>() + }) + + test('object does not have toString', () => { + expectTypeOf>().toEqualTypeOf<{ + foo: string + }>() + }) + + test('empty object', () => { + expectTypeOf>().toEqualTypeOf<{}>() + }) + + test('object type', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('nubmer', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('string', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('symbol', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('bigint', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('array', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('boolean', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('undefined', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('null', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('record', () => { + expectTypeOf>>().toEqualTypeOf< + Record + >() + }) + + test('tuple', () => { + expectTypeOf>().toEqualTypeOf<[1, 2]>() + }) + + test('function', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('literal number', () => { + expectTypeOf>().toEqualTypeOf<1>() + }) + + test('literal bigint', () => { + expectTypeOf< + StringConvertable<9007199254740992n> + >().toEqualTypeOf<9007199254740992n>() + }) + + test('literal string', () => { + expectTypeOf>().toEqualTypeOf<'hello'>() + }) + + test('literal boolean', () => { + expectTypeOf>().toEqualTypeOf() + }) + + test('literal function', () => { + expectTypeOf {}>>().toEqualTypeOf<() => {}>() + }) +}) diff --git a/packages/vue-i18n-core/src/i18n.ts b/packages/vue-i18n-core/src/i18n.ts index 4404d1a6a..d46a0293b 100644 --- a/packages/vue-i18n-core/src/i18n.ts +++ b/packages/vue-i18n-core/src/i18n.ts @@ -1,61 +1,61 @@ import { - inject, - onMounted, - onUnmounted, - InjectionKey, - getCurrentInstance, - isRef, - effectScope -} from 'vue' -import { - isEmptyObject, + assign, + createEmitter, isBoolean, + isEmptyObject, isPlainObject, - warn, makeSymbol, - createEmitter, - assign + warn } from '@intlify/shared' +import { + InjectionKey, + effectScope, + getCurrentInstance, + inject, + isRef, + onMounted, + onUnmounted +} from 'vue' import { createComposer } from './composer' -import { createVueI18n } from './legacy' -import { I18nWarnCodes, getWarnMessage } from './warnings' +import { addTimelineEvent, enableDevTools } from './devtools' import { I18nErrorCodes, createI18nError } from './errors' +import { createVueI18n } from './legacy' +import { defineMixin } from './mixins' +import { apply as applyPlugin } from './plugin/next' import { - EnableEmitter, DisableEmitter, DisposeSymbol, + EnableEmitter, InejctWithOptionSymbol } from './symbols' -import { apply as applyPlugin } from './plugin/next' -import { defineMixin } from './mixins' -import { enableDevTools, addTimelineEvent } from './devtools' -import { getComponentOptions, adjustI18nResources } from './utils' +import { adjustI18nResources, getComponentOptions } from './utils' +import { I18nWarnCodes, getWarnMessage } from './warnings' -import type { ComponentInternalInstance, App, EffectScope } from 'vue' import type { - Locale, FallbackLocale, - SchemaParams, - LocaleParams + Locale, + LocaleParams, + SchemaParams } from '@intlify/core-base' import type { VueDevToolsEmitter, VueDevToolsEmitterEvents } from '@intlify/devtools-types' +import type { App, ComponentInternalInstance, EffectScope } from 'vue' import type { - VueMessageType, - DefaultLocaleMessageSchema, - DefaultDateTimeFormatSchema, - DefaultNumberFormatSchema, Composer, + ComposerInternalOptions, ComposerOptions, - ComposerInternalOptions + DefaultDateTimeFormatSchema, + DefaultLocaleMessageSchema, + DefaultNumberFormatSchema, + VueMessageType } from './composer' import type { VueI18n, - VueI18nOptions, + VueI18nExtender, VueI18nInternal, - VueI18nExtender + VueI18nOptions } from './legacy' import type { Disposer } from './types' diff --git a/packages/vue-i18n-core/src/utils.ts b/packages/vue-i18n-core/src/utils.ts index b27595261..96bc77a58 100644 --- a/packages/vue-i18n-core/src/utils.ts +++ b/packages/vue-i18n-core/src/utils.ts @@ -1,28 +1,28 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { + deepCopy, + hasOwn, isArray, isObject, - hasOwn, isPlainObject, isString, - deepCopy, warn } from '@intlify/shared' import { Text, createVNode } from 'vue' import { I18nWarnCodes, getWarnMessage } from './warnings' import type { Locale, MessageResolver } from '@intlify/core-base' +import type { + ComponentInternalInstance, + RendererElement, + RendererNode +} from 'vue' import type { Composer, ComposerOptions, CustomBlocks, VueMessageType } from './composer' -import type { - ComponentInternalInstance, - RendererNode, - RendererElement -} from 'vue' type GetLocaleMessagesOptions = { messages?: { [K in keyof Messages]: Messages[K] } diff --git a/packages/vue-i18n-core/test/components/DatetimeFormat.test.ts b/packages/vue-i18n-core/test/components/DatetimeFormat.test.ts index a24be8729..bfcda3058 100644 --- a/packages/vue-i18n-core/test/components/DatetimeFormat.test.ts +++ b/packages/vue-i18n-core/test/components/DatetimeFormat.test.ts @@ -2,17 +2,19 @@ * @vitest-environment jsdom */ -import { mount } from '../helper' -import { defineComponent, SetupContext, VNodeChild, h } from 'vue' import { compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, registerMessageCompiler, - resolveValue, registerMessageResolver, - fallbackWithLocaleChain, - registerLocaleFallbacker + resolveValue } from '@intlify/core-base' -import { createI18n, IntlDateTimeFormats } from '../../src/index' +import { defineComponent, h, SetupContext, VNodeChild } from 'vue' +import { createI18n } from '../../src/index' +import { mount } from '../helper' + +import type { IntlDateTimeFormats } from '../../src/index' const datetimeFormats: IntlDateTimeFormats = { 'en-US': { diff --git a/packages/vue-i18n-core/test/components/NumberFormat.test.ts b/packages/vue-i18n-core/test/components/NumberFormat.test.ts index ff4d9b3d3..5429075c8 100644 --- a/packages/vue-i18n-core/test/components/NumberFormat.test.ts +++ b/packages/vue-i18n-core/test/components/NumberFormat.test.ts @@ -2,19 +2,21 @@ * @vitest-environment jsdom */ -import { mount } from '../helper' -import { defineComponent, SetupContext, VNodeChild, h } from 'vue' import { compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, registerMessageCompiler, - resolveValue, registerMessageResolver, - fallbackWithLocaleChain, - registerLocaleFallbacker + resolveValue } from '@intlify/core-base' +import { defineComponent, h, SetupContext, VNodeChild } from 'vue' import { createI18n } from '../../src/index' +import { mount } from '../helper' + +import type { IntlNumberFormats } from '../../src/index' -const numberFormats = { +const numberFormats: IntlNumberFormats = { 'en-US': { currency: { style: 'currency', diff --git a/packages/vue-i18n-core/test/components/Translation.test.ts b/packages/vue-i18n-core/test/components/Translation.test.ts index 3e3b48cdf..c6525e1dd 100644 --- a/packages/vue-i18n-core/test/components/Translation.test.ts +++ b/packages/vue-i18n-core/test/components/Translation.test.ts @@ -2,27 +2,27 @@ * @vitest-environment jsdom */ -import { mount } from '../helper' -import { - h, - defineComponent, - SetupContext, - VNodeChild, - ref, - nextTick -} from 'vue' import { compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, registerMessageCompiler, - resolveValue, registerMessageResolver, - fallbackWithLocaleChain, - registerLocaleFallbacker + resolveValue } from '@intlify/core-base' +import { + defineComponent, + h, + nextTick, + ref, + SetupContext, + VNodeChild +} from 'vue' import { createI18n, useI18n } from '../../src/index' +import { mount } from '../helper' -import type { Ref } from 'vue' import type { Path, PathValue } from '@intlify/core-base' +import type { Ref } from 'vue' const messages = { en: { diff --git a/packages/vue-i18n-core/test/components/components.test-d.tsx b/packages/vue-i18n-core/test/components/components.test-d.tsx new file mode 100644 index 000000000..e37937b20 --- /dev/null +++ b/packages/vue-i18n-core/test/components/components.test-d.tsx @@ -0,0 +1,19 @@ +import 'vue/jsx' +import { DatetimeFormat, NumberFormat, Translation } from '../../src/components' + +test('components type check', () => { + // @ts-expect-error missing keypath + expectTypeOf().toEqualTypeOf() + // @ts-expect-error invalid props + expectTypeOf().toEqualTypeOf() + + expectTypeOf( + + ).toEqualTypeOf() + expectTypeOf( + + ).toEqualTypeOf() + expectTypeOf( + + ).toEqualTypeOf() +}) diff --git a/packages/vue-i18n-core/test/composer.test-d.ts b/packages/vue-i18n-core/test/composer.test-d.ts new file mode 100644 index 000000000..1e05f5461 --- /dev/null +++ b/packages/vue-i18n-core/test/composer.test-d.ts @@ -0,0 +1,382 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +import { createComposer } from '../src/composer' + +import type { + DateTimeFormat, + FallbackLocales, + NumberFormat, + PickupFallbackLocales +} from '@intlify/core-base' +import type { MyDatetimeScehma, MyNumberSchema, ResourceSchema } from './schema' + +declare module '../src/composer' { + interface ComposerCustom { + localeCode: string[] + } +} + +// loose options +const looseOptions = { + locale: 'en', + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + } + }, + ja: { + bar: 'foo', + nest: { + bar: 'bar' + } + } + }, + datetimeFormats: { + 'en-US': { + short: {} + } + }, + numberFormats: { + 'ja-JP': { + currency: {} + } + } +} + +// strict options +const strictOptions = { + locale: 'en', + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }, + ja: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error2'] + } + } +} + +test('loose composer', () => { + const looseComposer = createComposer(looseOptions) + + expectTypeOf(looseComposer.locale.value).toEqualTypeOf< + 'en' | 'ja' | 'en-US' | 'ja-JP' + >() + expectTypeOf(looseComposer.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'ja' + | 'en-US' + | 'ja-JP' + | ('en' | 'ja' | 'en-US' | 'ja-JP')[] + | { + [x in string]: PickupFallbackLocales< + ['en' | 'ja' | 'en-US' | 'ja-JP'] + >[] + } + | false + >() + expectTypeOf(looseComposer.messages.value).toEqualTypeOf<{ + en: { foo: string; nest: { bar: string } } + ja: { bar: string; nest: { bar: string } } + }>() + expectTypeOf(looseComposer.datetimeFormats.value).toEqualTypeOf<{ + 'en-US': { short: {} } + }>() + expectTypeOf(looseComposer.numberFormats.value).toEqualTypeOf<{ + 'ja-JP': { currency: {} } + }>() + expectTypeOf(looseComposer.t('nest.bar')).toEqualTypeOf() + expectTypeOf( + looseComposer.t('nest', 1, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + looseComposer.t('foo', 'default msg', { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + looseComposer.t('errors', [1], { plural: 1 }) + ).toEqualTypeOf() + expectTypeOf(looseComposer.t('errors', [1], 1)).toEqualTypeOf() + expectTypeOf( + looseComposer.t('errors', [1], 'default msg') + ).toEqualTypeOf() + expectTypeOf( + looseComposer.t(1, { foo: 1 }, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + looseComposer.t('nest', { foo: 1 }, 'msg') + ).toEqualTypeOf() + expectTypeOf(looseComposer.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(looseComposer.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(looseComposer.tm('errors')).toEqualTypeOf< + | string + | { + bar: string + } + | { + bar: string + } + | Record + >() + expectTypeOf(looseComposer.rt('foo')).toEqualTypeOf() + expectTypeOf(looseComposer.getLocaleMessage('en')).toEqualTypeOf< + typeof looseComposer.messages.value.en + >() + expectTypeOf( + looseComposer.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + expectTypeOf(looseComposer.localeCode).toEqualTypeOf() + + looseComposer.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + looseComposer.setLocaleMessage<{ dio: string }>('jojo', { + dio: 'The world!' + }) + looseComposer.mergeLocaleMessage('en', { + bar: 'foo' + }) + looseComposer.mergeLocaleMessage<{ dio: string }>('en', { + dio: 'The world!' + }) + + expectTypeOf(looseComposer.getDateTimeFormat('en-US')).toEqualTypeOf<{ + short: {} + }>() + expectTypeOf( + looseComposer.getLocaleMessage<{ long: { hour: string } }>('en-US') + ).toEqualTypeOf<{ long: { hour: string } }>() + + looseComposer.setDateTimeFormat('ja-JP', { + short: { + hour: 'numeric' + } + }) + looseComposer.setDateTimeFormat<{ stop: { hour: string } }>('world', { + stop: { hour: 'infinity' } + }) + looseComposer.mergeDateTimeFormat('en-US', { + long: { hour: 'numeric' } + }) + looseComposer.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { + stop: { hour: 'infinity' } + }) + + expectTypeOf(looseComposer.getNumberFormat('ja-JP')).toEqualTypeOf<{ + currency: {} + }>() + expectTypeOf( + looseComposer.getNumberFormat<{ weight: { unit: string } }>('en-US') + ).toEqualTypeOf<{ weight: { unit: string } }>() + + looseComposer.setNumberFormat('en-US', { + currency: { + currecy: 'USD' + } + }) + looseComposer.setNumberFormat<{ echoes: { act: string } }>('stand', { + echoes: { act: '2' } + }) + looseComposer.mergeNumberFormat('ja-JP', { + weight: { + unit: 'kiro' + } + }) + looseComposer.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { + echoes: { act: '2' } + }) +}) + +test('strict composer', () => { + const strictComposer = createComposer<[ResourceSchema], 'en' | 'ja'>( + strictOptions + ) + + expectTypeOf(strictComposer.locale.value).toEqualTypeOf<'en' | 'ja'>() + expectTypeOf(strictComposer.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'ja' + | ('en' | 'ja')[] + | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } + | false + >() + expectTypeOf(strictComposer.messages.value).toEqualTypeOf<{ + en: ResourceSchema + ja: ResourceSchema + }>() + expectTypeOf(strictComposer.datetimeFormats.value).toEqualTypeOf<{ + en: DateTimeFormat + ja: DateTimeFormat + }>() + expectTypeOf(strictComposer.numberFormats.value).toEqualTypeOf<{ + en: NumberFormat + ja: NumberFormat + }>() + expectTypeOf(strictComposer.t('nest.bar')).toEqualTypeOf() + expectTypeOf( + strictComposer.t('nest', 1, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictComposer.t('foo', 'default msg', { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictComposer.t('errors', [1], { plural: 1 }) + ).toEqualTypeOf() + expectTypeOf(strictComposer.t('errors', [1], 1)).toEqualTypeOf() + expectTypeOf( + strictComposer.t('errors', [1], 'default msg') + ).toEqualTypeOf() + expectTypeOf( + strictComposer.t(1, { foo: 1 }, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictComposer.t('nest', { foo: 1 }, 'msg') + ).toEqualTypeOf() + expectTypeOf(strictComposer.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(strictComposer.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(strictComposer.tm('errors')).toEqualTypeOf() + expectTypeOf(strictComposer.rt('foo')).toEqualTypeOf() + expectTypeOf(strictComposer.getLocaleMessage('en')).toEqualTypeOf< + typeof strictComposer.messages.value.en + >() + expectTypeOf( + strictComposer.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + + strictComposer.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + strictComposer.setLocaleMessage<{ dio: string }>('jojo', { + dio: 'The world!' + }) + strictComposer.mergeLocaleMessage('en', { + bar: 'foo' + }) + strictComposer.mergeLocaleMessage<{ dio: string }>('en', { + dio: 'The world!' + }) +}) + +test('strict composer with direct options', () => { + const strictDirectComposer = createComposer< + { + message: ResourceSchema + datetime: MyDatetimeScehma + number: MyNumberSchema + }, + { messages: 'en'; datetimeFormats: 'ja-JP' | 'zh'; numberFormats: 'ca' } + >({ + messages: { + en: { + foo: '', + nest: { + bar: '' + }, + errors: [''] + } + }, + datetimeFormats: { + zh: { + short: { + hour: 'numeric' + } + }, + 'ja-JP': { + short: { + hour: 'numeric' + } + } + }, + numberFormats: { + ca: { + currency: { + style: 'currency', + currencyDisplay: 'symbol' + } + } + } + }) + + expectTypeOf(strictDirectComposer.locale.value).toEqualTypeOf< + 'en' | 'zh' | 'ca' | 'ja-JP' + >() + expectTypeOf(strictDirectComposer.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'zh' + | 'ca' + | 'ja-JP' + | ('en' | 'zh' | 'ca' | 'ja-JP')[] + | { [x in string]: PickupFallbackLocales<['en' | 'zh' | 'ca' | 'ja-JP']>[] } + | false + >() + expectTypeOf(strictDirectComposer.messages.value).toEqualTypeOf<{ + en: ResourceSchema + }>() + expectTypeOf(strictDirectComposer.datetimeFormats.value).toEqualTypeOf<{ + zh: { short: { hour: 'numeric' } } + 'ja-JP': { short: { hour: 'numeric' } } + }>() + expectTypeOf(strictDirectComposer.numberFormats.value).toEqualTypeOf<{ + ca: { currency: { style: 'currency'; currencyDisplay: 'symbol' } } + }>() + expectTypeOf(strictDirectComposer.d(new Date())).toEqualTypeOf() + expectTypeOf( + strictDirectComposer.d(new Date(), 'short', 'ja-JP') + ).toEqualTypeOf() + expectTypeOf( + strictDirectComposer.d(new Date(), { key: 'short', locale: 'zh' }) + ).toEqualTypeOf() + expectTypeOf( + strictDirectComposer.d(new Date(), 'custom' as any) + ).toEqualTypeOf() + expectTypeOf(strictDirectComposer.n(1)).toEqualTypeOf() + expectTypeOf( + strictDirectComposer.n(1, 'currency', 'zh') + ).toEqualTypeOf() + expectTypeOf( + strictDirectComposer.n(1, { key: 'currency', locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictDirectComposer.n(1, 'custom' as any) + ).toEqualTypeOf() + + // const noOptionsComposer = createComposer({ missingWarn: true }) + const noOptionsComposer = createComposer({ locale: 'en' }) + expectTypeOf(noOptionsComposer.locale.value).toEqualTypeOf() + expectTypeOf(noOptionsComposer.fallbackLocale.value).toEqualTypeOf< + FallbackLocales + >() + + const nullComposer = createComposer({}) + expectTypeOf(nullComposer.locale.value).toEqualTypeOf() + nullComposer.locale.value = 'en' + expectTypeOf(nullComposer.fallbackLocale.value).toEqualTypeOf< + FallbackLocales + >() + nullComposer.fallbackLocale.value = 'fr' +}) + +/* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/packages/vue-i18n-core/test/i18n.test-d.ts b/packages/vue-i18n-core/test/i18n.test-d.ts new file mode 100644 index 000000000..78facc5c4 --- /dev/null +++ b/packages/vue-i18n-core/test/i18n.test-d.ts @@ -0,0 +1,616 @@ +import * as vueI18n from '../src/i18n' +import { createI18n, useI18n } from '../src/i18n' + +import type { + DateTimeFormat, + NumberFormat, + PickupFallbackLocales +} from '@intlify/core-base' +import type { MyDatetimeScehma, MyNumberSchema, ResourceSchema } from './schema' + +beforeEach(() => { + // allow mocking + vi.spyOn(vueI18n, 'useI18n').mockReturnValue(>{ + t: (key: string) => `{{${key}}}` + }) +}) + +afterEach(() => { + vi.resetAllMocks() +}) + +// loose options +const looseOptions = { + locale: 'en', + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + } + }, + ja: { + bar: 'foo', + nest: { + bar: 'bar' + } + } + }, + datetimeFormats: { + 'en-US': { + short: {} + } + }, + numberFormats: { + 'ja-JP': { + currency: {} + } + } +} + +// strict options +const strictOptions = { + locale: 'en', + legacy: false, + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }, + ja: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error2'] + } + } +} + +test('loose composer with useI18n', () => { + const looseI18n = useI18n(looseOptions) + + expectTypeOf(looseI18n.locale.value).toEqualTypeOf< + 'en' | 'ja' | 'en-US' | 'ja-JP' + >() + expectTypeOf(looseI18n.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'ja' + | 'en-US' + | 'ja-JP' + | ('en' | 'ja' | 'en-US' | 'ja-JP')[] + | { + [x in string]: PickupFallbackLocales< + ['en' | 'ja' | 'en-US' | 'ja-JP'] + >[] + } + | false + >() + expectTypeOf(looseI18n.messages.value).toEqualTypeOf<{ + en: { + foo: string + nest: { + bar: string + } + } + ja: { + bar: string + nest: { + bar: string + } + } + }>() + + expectTypeOf(looseI18n.datetimeFormats.value).toEqualTypeOf<{ + 'en-US': { short: {} } + }>() + expectTypeOf(looseI18n.numberFormats.value).toEqualTypeOf<{ + 'ja-JP': { currency: {} } + }>() + expectTypeOf(looseI18n.t('nest.bar')).toEqualTypeOf() + expectTypeOf(looseI18n.t('nest', 1, { locale: 'en' })).toEqualTypeOf() + expectTypeOf( + looseI18n.t('foo', 'default msg', { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + looseI18n.t('errors', [1], { plural: 1 }) + ).toEqualTypeOf() + expectTypeOf(looseI18n.t('errors', [1], 1)).toEqualTypeOf() + expectTypeOf( + looseI18n.t('errors', [1], 'default msg') + ).toEqualTypeOf() + expectTypeOf( + looseI18n.t(1, { foo: 1 }, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf(looseI18n.t('nest', { foo: 1 }, 'msg')).toEqualTypeOf() + expectTypeOf(looseI18n.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(looseI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(looseI18n.tm('errors')).toEqualTypeOf< + | string + | { + bar: string + } + | { + bar: string + } + | Record + >() + expectTypeOf(looseI18n.rt('foo')).toEqualTypeOf() + expectTypeOf(looseI18n.getLocaleMessage('en')).toEqualTypeOf< + typeof looseI18n.messages.value.en + >() + expectTypeOf( + looseI18n.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + + looseI18n.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + looseI18n.setLocaleMessage<{ dio: string }>('jojo', { + dio: 'The world!' + }) + looseI18n.mergeLocaleMessage('en', { + bar: 'foo' + }) + looseI18n.mergeLocaleMessage<{ dio: string }>('en', { + dio: 'The world!' + }) + + expectTypeOf(looseI18n.getDateTimeFormat('en-US')).toEqualTypeOf< + (typeof looseI18n.datetimeFormats.value)['en-US'] + >() + expectTypeOf( + looseI18n.getLocaleMessage<{ long: { hour: string } }>('en-US') + ).toEqualTypeOf<{ long: { hour: string } }>() + + looseI18n.setDateTimeFormat('ja-JP', { + short: { + hour: 'numeric' + } + }) + looseI18n.setDateTimeFormat<{ stop: { hour: string } }>('world', { + stop: { hour: 'infinity' } + }) + looseI18n.mergeDateTimeFormat('en-US', { + long: { hour: 'numeric' } + }) + looseI18n.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { + stop: { hour: 'infinity' } + }) + + expectTypeOf(looseI18n.getNumberFormat('ja-JP')).toEqualTypeOf< + (typeof looseI18n.numberFormats.value)['ja-JP'] + >() + expectTypeOf( + looseI18n.getNumberFormat<{ weight: { unit: string } }>('en-US') + ).toEqualTypeOf<{ weight: { unit: string } }>() + + looseI18n.setNumberFormat('en-US', { + currency: { + currecy: 'USD' + } + }) + looseI18n.setNumberFormat<{ echoes: { act: string } }>('stand', { + echoes: { act: '2' } + }) + looseI18n.mergeNumberFormat('ja-JP', { + weight: { + unit: 'kiro' + } + }) + looseI18n.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { + echoes: { act: '2' } + }) +}) + +test('strict composer with useI18n', () => { + const strictI18n = useI18n<[ResourceSchema], 'en' | 'ja'>(strictOptions) + + expectTypeOf(strictI18n.locale.value).toEqualTypeOf<'en' | 'ja'>() + expectTypeOf(strictI18n.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'ja' + | ('en' | 'ja')[] + | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } + | false + >() + expectTypeOf(strictI18n.messages.value).toEqualTypeOf<{ + en: ResourceSchema + ja: ResourceSchema + }>() + expectTypeOf(strictI18n.datetimeFormats.value).toEqualTypeOf<{ + en: DateTimeFormat + ja: DateTimeFormat + }>() + expectTypeOf(strictI18n.numberFormats.value).toEqualTypeOf<{ + en: NumberFormat + ja: NumberFormat + }>() + + expectTypeOf(strictI18n.t('nest.bar')).toEqualTypeOf() + expectTypeOf( + strictI18n.t('nest', 1, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictI18n.t('foo', 'default msg', { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictI18n.t('errors', [1], { plural: 1 }) + ).toEqualTypeOf() + expectTypeOf(strictI18n.t('errors', [1], 1)).toEqualTypeOf() + expectTypeOf( + strictI18n.t('errors', [1], 'default msg') + ).toEqualTypeOf() + expectTypeOf( + strictI18n.t(1, { foo: 1 }, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf(strictI18n.t('nestt', { foo: 1 }, 'msg')).toEqualTypeOf() + expectTypeOf(strictI18n.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(strictI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(strictI18n.tm('errors')).toEqualTypeOf() + expectTypeOf(strictI18n.rt('foo')).toEqualTypeOf() + expectTypeOf(strictI18n.getLocaleMessage('en')).toEqualTypeOf< + typeof strictI18n.messages.value.en + >() + expectTypeOf( + strictI18n.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + + strictI18n.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + strictI18n.setLocaleMessage<{ dio: string }>('jojo', { + dio: 'The world!' + }) + strictI18n.mergeLocaleMessage('en', { + bar: 'foo' + }) + strictI18n.mergeLocaleMessage<{ dio: string }>('en', { + dio: 'The world!' + }) +}) + +test('global scope with type annotation at useI18n', () => { + const globalComposer = useI18n<[ResourceSchema], 'en' | 'ja'>({ + inheritLocale: true, + useScope: 'global' + }) + + expectTypeOf(globalComposer.locale.value).toEqualTypeOf<'en' | 'ja'>() + expectTypeOf( + globalComposer.t('nest.bar', { foo: 1 }, { locale: 'en' }) + ).toEqualTypeOf() +}) + +test('local scope without type annotation at useI18n', () => { + const localComposer = useI18n({ + useScope: 'local' + }) + expectTypeOf(localComposer.locale.value).toEqualTypeOf() +}) + +test('loose i18n', () => { + // with object spread and composer + const looseI18nComposer = createI18n({ + ...looseOptions, + legacy: false + }).global + + expectTypeOf(looseI18nComposer.locale.value).toEqualTypeOf< + 'en' | 'ja' | 'en-US' | 'ja-JP' + >() + expectTypeOf(looseI18nComposer.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'ja' + | 'en-US' + | 'ja-JP' + | ('en' | 'ja' | 'en-US' | 'ja-JP')[] + | { + [x in string]: PickupFallbackLocales< + ['en' | 'ja' | 'en-US' | 'ja-JP'] + >[] + } + | false + >() + expectTypeOf(looseI18nComposer.messages.value).toEqualTypeOf<{ + en: { + foo: string + nest: { + bar: string + } + } + ja: { + bar: string + nest: { + bar: string + } + } + }>() + + const looseI18n = createI18n(looseOptions).global + expectTypeOf(looseI18n.locale).toEqualTypeOf< + 'en' | 'ja' | 'en-US' | 'ja-JP' + >() + expectTypeOf(looseI18n.fallbackLocale).toEqualTypeOf< + | 'en' + | 'ja' + | 'en-US' + | 'ja-JP' + | ('en' | 'ja' | 'en-US' | 'ja-JP')[] + | { + [x in string]: PickupFallbackLocales< + ['en' | 'ja' | 'en-US' | 'ja-JP'] + >[] + } + | false + >() + expectTypeOf(looseI18n.messages).toEqualTypeOf<{ + en: { + foo: string + nest: { + bar: string + } + } + ja: { + bar: string + nest: { + bar: string + } + } + }>() + expectTypeOf(looseI18n.datetimeFormats).toEqualTypeOf<{ + 'en-US': { short: {} } + }>() + expectTypeOf(looseI18n.numberFormats).toEqualTypeOf<{ + 'ja-JP': { currency: {} } + }>() + expectTypeOf(looseI18n.t('nest.bar')).toEqualTypeOf() + expectTypeOf(looseI18n.t('nest', 'en')).toEqualTypeOf() + expectTypeOf(looseI18n.t('foo', [1])).toEqualTypeOf() + expectTypeOf(looseI18n.t('nest', { foo: 1 })).toEqualTypeOf() + expectTypeOf(looseI18n.tc('nest')).toEqualTypeOf() + expectTypeOf(looseI18n.tc('bar', 'en')).toEqualTypeOf() + expectTypeOf(looseI18n.tc('bar', ['foo'])).toEqualTypeOf() + expectTypeOf(looseI18n.tc('bar', { foo: 'foo' })).toEqualTypeOf() + expectTypeOf(looseI18n.tc('nest.bar', 1)).toEqualTypeOf() + expectTypeOf(looseI18n.tc('nest.bar', 1, ['bar'])).toEqualTypeOf() + expectTypeOf( + looseI18n.tc('nest.bar', 1, { foo: 'bar' }) + ).toEqualTypeOf() + expectTypeOf(looseI18n.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(looseI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(looseI18n.tm('errors')).toEqualTypeOf< + | string + | { + bar: string + } + | { + bar: string + } + | Record + >() + expectTypeOf(looseI18n.rt('foo')).toEqualTypeOf() + expectTypeOf(looseI18n.getLocaleMessage('en')).toEqualTypeOf< + typeof looseI18n.messages.en + >() + expectTypeOf( + looseI18n.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + + looseI18n.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + looseI18n.setLocaleMessage<{ dio: string }>('jojo', { + dio: 'The world!' + }) + looseI18n.mergeLocaleMessage('en', { + bar: 'foo' + }) + looseI18n.mergeLocaleMessage<{ dio: string }>('en', { + dio: 'The world!' + }) + + expectTypeOf(looseI18n.getDateTimeFormat('en-US')).toEqualTypeOf< + (typeof looseI18n.datetimeFormats)['en-US'] + >() + expectTypeOf( + looseI18n.getLocaleMessage<{ long: { hour: string } }>('en-US') + ).toEqualTypeOf<{ long: { hour: string } }>() + + looseI18n.setDateTimeFormat('ja-JP', { + short: { + hour: 'numeric' + } + }) + looseI18n.setDateTimeFormat<{ stop: { hour: string } }>('world', { + stop: { hour: 'infinity' } + }) + looseI18n.mergeDateTimeFormat('en-US', { + long: { hour: 'numeric' } + }) + looseI18n.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { + stop: { hour: 'infinity' } + }) + + expectTypeOf(looseI18n.getNumberFormat('ja-JP')).toEqualTypeOf< + (typeof looseI18n.numberFormats)['ja-JP'] + >() + expectTypeOf( + looseI18n.getNumberFormat<{ weight: { unit: string } }>('en-US') + ).toEqualTypeOf<{ weight: { unit: string } }>() + + looseI18n.setNumberFormat('en-US', { + currency: { + currecy: 'USD' + } + }) + looseI18n.setNumberFormat<{ echoes: { act: string } }>('stand', { + echoes: { act: '2' } + }) + looseI18n.mergeNumberFormat('ja-JP', { + weight: { + unit: 'kiro' + } + }) + looseI18n.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { + echoes: { act: '2' } + }) +}) + +test('strict i18n', () => { + const strictI18n = createI18n<[ResourceSchema], 'en' | 'ja', false>( + strictOptions + ).global + + expectTypeOf(strictI18n.locale.value).toEqualTypeOf<'en' | 'ja'>() + expectTypeOf(strictI18n.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'ja' + | ('en' | 'ja')[] + | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } + | false + >() + expectTypeOf(strictI18n.messages.value).toEqualTypeOf<{ + en: ResourceSchema + ja: ResourceSchema + }>() + expectTypeOf(strictI18n.datetimeFormats.value).toEqualTypeOf<{ + en: DateTimeFormat + ja: DateTimeFormat + }>() + expectTypeOf(strictI18n.numberFormats.value).toEqualTypeOf<{ + en: NumberFormat + ja: NumberFormat + }>() + expectTypeOf(strictI18n.t('nest.bar')).toEqualTypeOf() + expectTypeOf( + strictI18n.t('nest', 1, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictI18n.t('foo', 'default msg', { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf( + strictI18n.t('errors', [1], { plural: 1 }) + ).toEqualTypeOf() + expectTypeOf(strictI18n.t('errors', [1], 1)).toEqualTypeOf() + expectTypeOf( + strictI18n.t('errors', [1], 'default msg') + ).toEqualTypeOf() + expectTypeOf( + strictI18n.t(1, { foo: 1 }, { locale: 'en' }) + ).toEqualTypeOf() + expectTypeOf(strictI18n.t('nest', { foo: 1 }, 'msg')).toEqualTypeOf() + expectTypeOf(strictI18n.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(strictI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(strictI18n.tm('errors')).toEqualTypeOf() + expectTypeOf(strictI18n.rt('foo')).toEqualTypeOf() + expectTypeOf(strictI18n.getLocaleMessage('en')).toEqualTypeOf< + typeof strictI18n.messages.value.en + >() + expectTypeOf( + strictI18n.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + + strictI18n.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + strictI18n.setLocaleMessage<{ dio: string }>('jojo', { + dio: 'The world!' + }) + strictI18n.mergeLocaleMessage('en', { + bar: 'foo' + }) + strictI18n.mergeLocaleMessage<{ dio: string }>('en', { + dio: 'The world!' + }) +}) + +test('strict i18n with direct i18n options', () => { + const strictDirectI18n = createI18n< + { + message: ResourceSchema + datetime: MyDatetimeScehma + number: MyNumberSchema + }, + { messages: 'en'; datetimeFormats: 'ja-JP' | 'zh'; numberFormats: 'ca' }, + false + >({ + messages: { + en: { + foo: '', + nest: { + bar: '' + }, + errors: [''] + } + }, + datetimeFormats: { + zh: { + short: { + hour: 'numeric' + } + }, + 'ja-JP': { + short: { + hour: 'numeric' + } + } + }, + numberFormats: { + ca: { + currency: { + style: 'currency', + currencyDisplay: 'symbol' + } + } + } + }).global + + expectTypeOf(strictDirectI18n.locale.value).toEqualTypeOf< + 'en' | 'zh' | 'ca' | 'ja-JP' + >() + expectTypeOf(strictDirectI18n.fallbackLocale.value).toEqualTypeOf< + | 'en' + | 'zh' + | 'ca' + | 'ja-JP' + | ('en' | 'zh' | 'ca' | 'ja-JP')[] + | { [x in string]: PickupFallbackLocales<['en' | 'zh' | 'ca' | 'ja-JP']>[] } + | false + >() + expectTypeOf(strictDirectI18n.messages.value).toEqualTypeOf<{ + en: ResourceSchema + }>() + expectTypeOf(strictDirectI18n.datetimeFormats.value).toEqualTypeOf<{ + zh: { short: { hour: 'numeric' } } + 'ja-JP': { short: { hour: 'numeric' } } + }>() + expectTypeOf(strictDirectI18n.numberFormats.value).toEqualTypeOf<{ + ca: { currency: { style: 'currency'; currencyDisplay: 'symbol' } } + }>() +}) diff --git a/packages/vue-i18n-core/test/issues.test.ts b/packages/vue-i18n-core/test/issues.test.ts index f3db536b7..2b3be11e0 100644 --- a/packages/vue-i18n-core/test/issues.test.ts +++ b/packages/vue-i18n-core/test/issues.test.ts @@ -13,29 +13,28 @@ vi.mock('@intlify/shared', async () => { }) import { - ref, - defineComponent, - h, - withDirectives, - resolveDirective, - nextTick, - getCurrentInstance, - onMounted -} from 'vue' -import { - setDevToolsHook, compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, registerMessageCompiler, - resolveValue, registerMessageResolver, - fallbackWithLocaleChain, - registerLocaleFallbacker + resolveValue, + setDevToolsHook } from '@intlify/core-base' +import { + defineComponent, + getCurrentInstance, + h, + nextTick, + ref, + resolveDirective, + withDirectives +} from 'vue' import { createI18n, useI18n } from '../src/i18n' import { mount } from './helper' import type { ComponentOptions } from 'vue' -import type { IntlDateTimeFormats } from '../src/index' +import type { IntlDateTimeFormats, IntlNumberFormats } from '../src/index' const container = document.createElement('div') document.body.appendChild(container) @@ -111,7 +110,7 @@ const datetimeFormats: IntlDateTimeFormats = { } } -const numberFormats = { +const numberFormats: IntlNumberFormats = { 'en-US': { currency: { style: 'currency', @@ -1210,7 +1209,7 @@ test('issue #1610', async () => { test('issue #1615', async () => { const en = { hello: (() => { - const fn = ctx => { + const fn = (ctx: any) => { const { normalize: _normalize } = ctx return _normalize(['Hello, Vue I18n']) } @@ -1218,7 +1217,7 @@ test('issue #1615', async () => { return fn })(), language: (() => { - const fn = ctx => { + const fn = (ctx: any) => { const { normalize: _normalize } = ctx return _normalize(['Languages']) } diff --git a/packages/vue-i18n-core/test/legacy.test-d.ts b/packages/vue-i18n-core/test/legacy.test-d.ts new file mode 100644 index 000000000..92af647fd --- /dev/null +++ b/packages/vue-i18n-core/test/legacy.test-d.ts @@ -0,0 +1,249 @@ +import { createVueI18n } from '../src/legacy' + +import type { + DateTimeFormat, + FallbackLocale, + Locale, + NumberFormat, + PickupFallbackLocales +} from '@intlify/core-base' +import type { ResourceSchema } from './schema' + +// loose options +const looseOptions = { + locale: 'en', + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }, + ja: { + bar: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error2'] + } + }, + datetimeFormats: { + 'en-US': { + short: {} + } + }, + numberFormats: { + 'ja-JP': { + currency: {} + } + } +} + +// strict options +const strictOptions = { + locale: 'en', + fallbackLocale: { + ja: ['en'] + }, + messages: { + en: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }, + ja: { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error2'] + } + } +} + +test('loose legacy', () => { + const looseVueI18n = createVueI18n(looseOptions) + + expectTypeOf(looseVueI18n.locale).toEqualTypeOf< + 'en' | 'ja' | 'en-US' | 'ja-JP' + >() + expectTypeOf(looseVueI18n.fallbackLocale).toEqualTypeOf< + | 'en' + | 'ja' + | 'en-US' + | 'ja-JP' + | ('en' | 'ja' | 'en-US' | 'ja-JP')[] + | { + [x in string]: PickupFallbackLocales< + ['en' | 'ja' | 'en-US' | 'ja-JP'] + >[] + } + | false + >() + expectTypeOf(looseVueI18n.messages).toEqualTypeOf<{ + en: { foo: string; nest: { bar: string }; errors: string[] } + ja: { bar: string; nest: { bar: string }; errors: string[] } + }>() + expectTypeOf(looseVueI18n.datetimeFormats).toEqualTypeOf<{ + 'en-US': { short: {} } + }>() + expectTypeOf(looseVueI18n.numberFormats).toEqualTypeOf<{ + 'ja-JP': { currency: {} } + }>() + expectTypeOf(looseVueI18n.t('nest.bar')).toEqualTypeOf() + expectTypeOf(looseVueI18n.t('nest', 'en')).toEqualTypeOf() + expectTypeOf(looseVueI18n.t('foo', [1])).toEqualTypeOf() + expectTypeOf(looseVueI18n.t('nest', { foo: 1 })).toEqualTypeOf() + expectTypeOf(looseVueI18n.tc('nest')).toEqualTypeOf() + expectTypeOf(looseVueI18n.tc('bar', 'en')).toEqualTypeOf() + expectTypeOf(looseVueI18n.tc('bar', ['foo'])).toEqualTypeOf() + expectTypeOf(looseVueI18n.tc('bar', { foo: 'foo' })).toEqualTypeOf() + expectTypeOf(looseVueI18n.tc('nest.bar', 1)).toEqualTypeOf() + expectTypeOf(looseVueI18n.tc('nest.bar', 1, ['bar'])).toEqualTypeOf() + expectTypeOf( + looseVueI18n.tc('nest.bar', 1, { foo: 'bar' }) + ).toEqualTypeOf() + expectTypeOf(looseVueI18n.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(looseVueI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(looseVueI18n.tm('errors')).toEqualTypeOf() + expectTypeOf(looseVueI18n.rt('foo')).toEqualTypeOf() + expectTypeOf(looseVueI18n.getLocaleMessage('en')).toEqualTypeOf<{ + foo: string + nest: { bar: string } + errors: string[] + }>() + expectTypeOf( + looseVueI18n.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + + looseVueI18n.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + looseVueI18n.setLocaleMessage<{ dio: string }>('jojo', { dio: 'dio' }) + looseVueI18n.mergeLocaleMessage('en', { + bar: 'foo' + }) + looseVueI18n.setDateTimeFormat('ja-JP', { + short: { + hour: 'numeric' + } + }) + looseVueI18n.setDateTimeFormat<{ stop: { hour: string } }>('world', { + stop: { hour: 'infinity' } + }) + looseVueI18n.mergeDateTimeFormat('en-US', { + long: { hour: 'numeric' } + }) + looseVueI18n.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { + stop: { hour: 'infinity' } + }) + + expectTypeOf(looseVueI18n.getDateTimeFormat('en-US')).toEqualTypeOf<{ + short: {} + }>() + expectTypeOf( + looseVueI18n.getDateTimeFormat<{ long: { hour: string } }>('en-US') + ).toEqualTypeOf<{ long: { hour: string } }>() + + looseVueI18n.setNumberFormat('en-US', { + currency: { + currecy: 'USD' + } + }) + looseVueI18n.setNumberFormat<{ echoes: { act: string } }>('stand', { + echoes: { act: '2' } + }) + looseVueI18n.mergeNumberFormat('ja-JP', { + weight: { + unit: 'kiro' + } + }) + looseVueI18n.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { + echoes: { act: '2' } + }) +}) + +test('strict legacy', () => { + const strictVueI18n = createVueI18n<[ResourceSchema], 'en' | 'ja'>( + strictOptions + ) + + expectTypeOf(strictVueI18n.locale).toEqualTypeOf<'en' | 'ja'>() + expectTypeOf(strictVueI18n.fallbackLocale).toEqualTypeOf< + | 'en' + | 'ja' + | ('en' | 'ja')[] + | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } + | false + >() + expectTypeOf(strictVueI18n.messages).toEqualTypeOf<{ + en: { foo: string; nest: { bar: string }; errors: string[] } + ja: { foo: string; nest: { bar: string }; errors: string[] } + }>() + expectTypeOf(strictVueI18n.datetimeFormats).toEqualTypeOf<{ + en: DateTimeFormat + ja: DateTimeFormat + }>() + expectTypeOf(strictVueI18n.numberFormats).toEqualTypeOf<{ + en: NumberFormat + ja: NumberFormat + }>() + expectTypeOf(strictVueI18n.t('nest.bar')).toEqualTypeOf() + expectTypeOf(strictVueI18n.t('nest', 'en')).toEqualTypeOf() + expectTypeOf(strictVueI18n.t('foo', [1])).toEqualTypeOf() + expectTypeOf(strictVueI18n.t('nest', { foo: 1 })).toEqualTypeOf() + expectTypeOf(strictVueI18n.tc('nest')).toEqualTypeOf() + expectTypeOf(strictVueI18n.tc('bar', 'en')).toEqualTypeOf() + expectTypeOf(strictVueI18n.tc('bar', ['foo'])).toEqualTypeOf() + expectTypeOf(strictVueI18n.tc('bar', { foo: 'foo' })).toEqualTypeOf() + expectTypeOf(strictVueI18n.tc('nest.bar', 1)).toEqualTypeOf() + expectTypeOf(strictVueI18n.tc('nest.bar', 1, ['bar'])).toEqualTypeOf() + expectTypeOf( + strictVueI18n.tc('nest.bar', 1, { foo: 'bar' }) + ).toEqualTypeOf() + expectTypeOf(strictVueI18n.te('errors', 'en')).toEqualTypeOf() + expectTypeOf(strictVueI18n.tm('nest')).toEqualTypeOf<{ bar: string }>() + expectTypeOf(strictVueI18n.tm('errors')).toEqualTypeOf() + expectTypeOf(strictVueI18n.rt('foo')).toEqualTypeOf() + expectTypeOf(strictVueI18n.getLocaleMessage('en')).toEqualTypeOf<{ + foo: string + nest: { bar: string } + errors: string[] + }>() + expectTypeOf( + strictVueI18n.getLocaleMessage<{ japan: string }>('japan') + ).toEqualTypeOf<{ japan: string }>() + + strictVueI18n.setLocaleMessage('en', { + foo: 'foo', + nest: { + bar: 'bar' + }, + errors: ['error1'] + }) + strictVueI18n.setLocaleMessage<{ dio: string }>('jojo', { + dio: 'The world!' + }) + strictVueI18n.mergeLocaleMessage('en', { + bar: 'foo' + }) + strictVueI18n.mergeLocaleMessage<{ dio: string }>('en', { + dio: 'The world!' + }) + + const nullVueI18n = createVueI18n({}) + expectTypeOf(nullVueI18n.locale).toEqualTypeOf() + nullVueI18n.locale = 'en' + expectTypeOf(nullVueI18n.fallbackLocale).toEqualTypeOf() + nullVueI18n.fallbackLocale = 'fr' +}) diff --git a/packages/vue-i18n-core/test/mixin.test.ts b/packages/vue-i18n-core/test/mixin.test.ts index 3db7d9720..02b8b4c91 100644 --- a/packages/vue-i18n-core/test/mixin.test.ts +++ b/packages/vue-i18n-core/test/mixin.test.ts @@ -12,19 +12,19 @@ vi.mock('@intlify/shared', async () => { } }) -import { mount } from './helper' -import { defineComponent, nextTick } from 'vue' import { compile, + fallbackWithLocaleChain, + registerLocaleFallbacker, registerMessageCompiler, - resolveValue, registerMessageResolver, - fallbackWithLocaleChain, - registerLocaleFallbacker + resolveValue } from '@intlify/core-base' -import { createI18n } from '../src/index' +import { defineComponent, nextTick } from 'vue' import { errorMessages, I18nErrorCodes } from '../src/errors' +import { createI18n } from '../src/index' import { VueI18n } from '../src/legacy' +import { mount } from './helper' beforeAll(() => { registerMessageCompiler(compile) diff --git a/packages/vue-i18n-core/test/schema.ts b/packages/vue-i18n-core/test/schema.ts new file mode 100644 index 000000000..bd077eb1b --- /dev/null +++ b/packages/vue-i18n-core/test/schema.ts @@ -0,0 +1,20 @@ +export type ResourceSchema = { + foo: string + nest: { + bar: string + } + errors: string[] +} + +export type MyDatetimeScehma = { + short: { + hour: 'numeric' + } +} + +export type MyNumberSchema = { + currency: { + style: 'currency' + currencyDisplay: 'symbol' + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0eedc5ecc..24692d864 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -161,7 +161,7 @@ importers: version: 1.4.0 rollup-plugin-typescript2: specifier: ^0.36.0 - version: 0.36.0(rollup@3.29.4)(typescript@5.3.3) + version: 0.36.0(rollup@3.29.4)(typescript@5.5.4) secretlint: specifier: ^3.2.0 version: 3.3.0 @@ -229,20 +229,20 @@ importers: specifier: ^4.11.2 version: 4.11.2 typescript: - specifier: ^5.3.3 - version: 5.3.3 + specifier: ^5.5.3 + version: 5.5.4 typescript-eslint: specifier: ^8.4.0 - version: 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) + version: 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) vitepress: specifier: 1.3.4 - version: 1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.3.3) + version: 1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.5.4) vitest: specifier: ^2.0.4 version: 2.0.4(@types/node@22.5.3)(jsdom@24.0.0)(terser@5.27.0) vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.3.3) + version: 3.4.38(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:packages/vue-i18n @@ -328,17 +328,17 @@ importers: dependencies: vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:../../../packages/vue-i18n vue-router: specifier: ^4.0.5 - version: 4.2.5(vue@3.4.38(typescript@5.4.3)) + version: 4.2.5(vue@3.4.38(typescript@5.5.4)) devDependencies: '@intlify/vue-i18n-loader': specifier: ^3.2.0 - version: 3.3.0(vue@3.4.38(typescript@5.4.3)) + version: 3.3.0(vue@3.4.38(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.2.0 version: 3.4.19 @@ -356,7 +356,7 @@ importers: version: 4.1.1(file-loader@6.2.0(webpack@4.47.0(webpack-cli@3.3.12)))(webpack@4.47.0(webpack-cli@3.3.12)) vue-loader: specifier: ^16.8.0 - version: 16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.4.38(typescript@5.4.3))(webpack@4.47.0(webpack-cli@3.3.12)) + version: 16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.4.38(typescript@5.5.4))(webpack@4.47.0(webpack-cli@3.3.12)) webpack: specifier: ^4.44.0 version: 4.47.0(webpack-cli@3.3.12) @@ -400,17 +400,17 @@ importers: dependencies: vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:../../packages/vue-i18n devDependencies: '@vitejs/plugin-vue': specifier: ^4.2.3 - version: 4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3)) + version: 4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) '@vitejs/plugin-vue-jsx': specifier: ^3.0.2 - version: 3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3)) + version: 3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -419,7 +419,7 @@ importers: version: 5.1.7(@types/node@22.5.3)(terser@5.27.0) vue-tsc: specifier: ^1.8.5 - version: 1.8.27(typescript@5.4.3) + version: 1.8.27(typescript@5.5.4) examples/type-safe/global-type-definition: dependencies: @@ -537,11 +537,11 @@ importers: version: 1.0.2 vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) devDependencies: '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3)) + version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -550,7 +550,7 @@ importers: version: 5.1.7(@types/node@22.5.3)(terser@5.27.0) vue-tsc: specifier: ^2.0.0 - version: 2.0.0(typescript@5.4.3) + version: 2.0.0(typescript@5.5.4) packages/message-compiler: dependencies: @@ -574,7 +574,7 @@ importers: version: 6.5.1 vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) devDependencies: '@intlify/devtools-types': specifier: workspace:* @@ -599,11 +599,11 @@ importers: version: link:../petite-vue-i18n vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) devDependencies: '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3)) + version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -612,20 +612,20 @@ importers: version: 5.1.7(@types/node@22.5.3)(terser@5.27.0) vue-tsc: specifier: ^2.0.0 - version: 2.0.0(typescript@5.4.3) + version: 2.0.0(typescript@5.5.4) packages/size-check-vue-i18n: dependencies: vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:../vue-i18n devDependencies: '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3)) + version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -634,7 +634,7 @@ importers: version: 5.1.7(@types/node@22.5.3)(terser@5.27.0) vue-tsc: specifier: ^2.0.0 - version: 2.0.0(typescript@5.4.3) + version: 2.0.0(typescript@5.5.4) packages/vue-i18n: dependencies: @@ -649,7 +649,7 @@ importers: version: 6.5.1 vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) devDependencies: '@intlify/devtools-types': specifier: workspace:* @@ -668,7 +668,7 @@ importers: version: 6.5.1 vue: specifier: 3.4.38 - version: 3.4.38(typescript@5.4.3) + version: 3.4.38(typescript@5.5.4) devDependencies: '@intlify/devtools-types': specifier: workspace:* @@ -6763,8 +6763,8 @@ packages: engines: {node: '>=14.17'} hasBin: true - typescript@5.4.3: - resolution: {integrity: sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==} + typescript@5.5.4: + resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} engines: {node: '>=14.17'} hasBin: true @@ -8064,14 +8064,14 @@ snapshots: '@intlify/shared': 9.13.1 optional: true - '@intlify/vue-i18n-loader@3.3.0(vue@3.4.38(typescript@5.4.3))': + '@intlify/vue-i18n-loader@3.3.0(vue@3.4.38(typescript@5.5.4))': dependencies: '@intlify/bundle-utils': 1.0.0 '@intlify/shared': 9.11.0 js-yaml: 4.1.0 json5: 2.2.3 loader-utils: 2.0.4 - vue: 3.4.38(typescript@5.4.3) + vue: 3.4.38(typescript@5.5.4) '@isaacs/cliui@8.0.2': dependencies: @@ -8880,34 +8880,34 @@ snapshots: '@types/web-bluetooth@0.0.20': {} - '@typescript-eslint/eslint-plugin@8.4.0(@typescript-eslint/parser@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3))(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3)': + '@typescript-eslint/eslint-plugin@8.4.0(@typescript-eslint/parser@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4))(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4)': dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) + '@typescript-eslint/parser': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) '@typescript-eslint/scope-manager': 8.4.0 - '@typescript-eslint/type-utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) - '@typescript-eslint/utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) + '@typescript-eslint/type-utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) + '@typescript-eslint/utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) '@typescript-eslint/visitor-keys': 8.4.0 eslint: 9.9.1(jiti@1.21.0) graphemer: 1.4.0 ignore: 5.3.1 natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.3.3) + ts-api-utils: 1.3.0(typescript@5.5.4) optionalDependencies: - typescript: 5.3.3 + typescript: 5.5.4 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3)': + '@typescript-eslint/parser@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4)': dependencies: '@typescript-eslint/scope-manager': 8.4.0 '@typescript-eslint/types': 8.4.0 - '@typescript-eslint/typescript-estree': 8.4.0(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 8.4.0(typescript@5.5.4) '@typescript-eslint/visitor-keys': 8.4.0 debug: 4.3.5(supports-color@6.1.0) eslint: 9.9.1(jiti@1.21.0) optionalDependencies: - typescript: 5.3.3 + typescript: 5.5.4 transitivePeerDependencies: - supports-color @@ -8916,21 +8916,21 @@ snapshots: '@typescript-eslint/types': 8.4.0 '@typescript-eslint/visitor-keys': 8.4.0 - '@typescript-eslint/type-utils@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3)': + '@typescript-eslint/type-utils@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4)': dependencies: - '@typescript-eslint/typescript-estree': 8.4.0(typescript@5.3.3) - '@typescript-eslint/utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 8.4.0(typescript@5.5.4) + '@typescript-eslint/utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) debug: 4.3.5(supports-color@6.1.0) - ts-api-utils: 1.3.0(typescript@5.3.3) + ts-api-utils: 1.3.0(typescript@5.5.4) optionalDependencies: - typescript: 5.3.3 + typescript: 5.5.4 transitivePeerDependencies: - eslint - supports-color '@typescript-eslint/types@8.4.0': {} - '@typescript-eslint/typescript-estree@8.4.0(typescript@5.3.3)': + '@typescript-eslint/typescript-estree@8.4.0(typescript@5.5.4)': dependencies: '@typescript-eslint/types': 8.4.0 '@typescript-eslint/visitor-keys': 8.4.0 @@ -8939,18 +8939,18 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.0 - ts-api-utils: 1.3.0(typescript@5.3.3) + ts-api-utils: 1.3.0(typescript@5.5.4) optionalDependencies: - typescript: 5.3.3 + typescript: 5.5.4 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3)': + '@typescript-eslint/utils@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.9.1(jiti@1.21.0)) '@typescript-eslint/scope-manager': 8.4.0 '@typescript-eslint/types': 8.4.0 - '@typescript-eslint/typescript-estree': 8.4.0(typescript@5.3.3) + '@typescript-eslint/typescript-estree': 8.4.0(typescript@5.5.4) eslint: 9.9.1(jiti@1.21.0) transitivePeerDependencies: - supports-color @@ -8961,13 +8961,13 @@ snapshots: '@typescript-eslint/types': 8.4.0 eslint-visitor-keys: 3.4.3 - '@vitejs/plugin-vue-jsx@3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3))': + '@vitejs/plugin-vue-jsx@3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': dependencies: '@babel/core': 7.23.9 '@babel/plugin-transform-typescript': 7.23.6(@babel/core@7.23.9) '@vue/babel-plugin-jsx': 1.2.1(@babel/core@7.23.9) vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.4.3) + vue: 3.4.38(typescript@5.5.4) transitivePeerDependencies: - supports-color @@ -8976,20 +8976,20 @@ snapshots: vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) vue: 3.4.38(typescript@5.3.3) - '@vitejs/plugin-vue@4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3))': + '@vitejs/plugin-vue@4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': dependencies: vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.4.3) + vue: 3.4.38(typescript@5.5.4) - '@vitejs/plugin-vue@5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.4.3))': + '@vitejs/plugin-vue@5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': dependencies: vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.4.3) + vue: 3.4.38(typescript@5.5.4) - '@vitejs/plugin-vue@5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.3.3))': + '@vitejs/plugin-vue@5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': dependencies: vite: 5.2.8(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.3.3) + vue: 3.4.38(typescript@5.5.4) '@vitest/coverage-v8@2.0.0(vitest@2.0.4(@types/node@22.5.3)(jsdom@24.0.0)(terser@5.27.0))': dependencies: @@ -9188,9 +9188,9 @@ snapshots: '@vue/compiler-dom': 3.4.38 '@vue/shared': 3.4.38 - '@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3))': + '@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4))': dependencies: - vue: 3.4.38(typescript@5.3.3) + vue: 3.4.38(typescript@5.5.4) optional: true '@vue/devtools-api@6.5.1': {} @@ -9227,7 +9227,7 @@ snapshots: optionalDependencies: typescript: 5.3.3 - '@vue/language-core@1.8.27(typescript@5.4.3)': + '@vue/language-core@1.8.27(typescript@5.5.4)': dependencies: '@volar/language-core': 1.11.1 '@volar/source-map': 1.11.1 @@ -9239,9 +9239,9 @@ snapshots: path-browserify: 1.0.1 vue-template-compiler: 2.7.16 optionalDependencies: - typescript: 5.4.3 + typescript: 5.5.4 - '@vue/language-core@2.0.0(typescript@5.4.3)': + '@vue/language-core@2.0.0(typescript@5.5.4)': dependencies: '@volar/language-core': 2.1.0 '@vue/compiler-dom': 3.4.34 @@ -9251,7 +9251,7 @@ snapshots: path-browserify: 1.0.1 vue-template-compiler: 2.7.16 optionalDependencies: - typescript: 5.4.3 + typescript: 5.5.4 '@vue/reactivity@3.4.38': dependencies: @@ -9275,11 +9275,11 @@ snapshots: '@vue/shared': 3.4.38 vue: 3.4.38(typescript@5.3.3) - '@vue/server-renderer@3.4.38(vue@3.4.38(typescript@5.4.3))': + '@vue/server-renderer@3.4.38(vue@3.4.38(typescript@5.5.4))': dependencies: '@vue/compiler-ssr': 3.4.38 '@vue/shared': 3.4.38 - vue: 3.4.38(typescript@5.4.3) + vue: 3.4.38(typescript@5.5.4) '@vue/shared@3.4.19': {} @@ -9287,21 +9287,21 @@ snapshots: '@vue/shared@3.4.38': {} - '@vueuse/core@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3))': + '@vueuse/core@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4))': dependencies: '@types/web-bluetooth': 0.0.20 '@vueuse/metadata': 11.0.3 - '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)) - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)) + '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) transitivePeerDependencies: - '@vue/composition-api' - vue - '@vueuse/integrations@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(focus-trap@7.5.4)(vue@3.4.38(typescript@5.3.3))': + '@vueuse/integrations@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(focus-trap@7.5.4)(vue@3.4.38(typescript@5.5.4))': dependencies: - '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)) - '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)) - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)) + '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) + '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) optionalDependencies: focus-trap: 7.5.4 transitivePeerDependencies: @@ -9310,9 +9310,9 @@ snapshots: '@vueuse/metadata@11.0.3': {} - '@vueuse/shared@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3))': + '@vueuse/shared@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4))': dependencies: - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -13540,7 +13540,7 @@ snapshots: process-es6: 0.11.6 rollup-pluginutils: 2.8.2 - rollup-plugin-typescript2@0.36.0(rollup@3.29.4)(typescript@5.3.3): + rollup-plugin-typescript2@0.36.0(rollup@3.29.4)(typescript@5.5.4): dependencies: '@rollup/pluginutils': 4.2.1 find-cache-dir: 3.3.2 @@ -13548,7 +13548,7 @@ snapshots: rollup: 3.29.4 semver: 7.6.0 tslib: 2.6.2 - typescript: 5.3.3 + typescript: 5.5.4 rollup-pluginutils@2.8.2: dependencies: @@ -14419,9 +14419,9 @@ snapshots: try-resolve@1.0.1: {} - ts-api-utils@1.3.0(typescript@5.3.3): + ts-api-utils@1.3.0(typescript@5.5.4): dependencies: - typescript: 5.3.3 + typescript: 5.5.4 tslib@2.6.2: {} @@ -14490,13 +14490,13 @@ snapshots: typedarray@0.0.6: {} - typescript-eslint@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3): + typescript-eslint@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4): dependencies: - '@typescript-eslint/eslint-plugin': 8.4.0(@typescript-eslint/parser@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3))(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) - '@typescript-eslint/parser': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) - '@typescript-eslint/utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.3.3) + '@typescript-eslint/eslint-plugin': 8.4.0(@typescript-eslint/parser@8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4))(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) + '@typescript-eslint/parser': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) + '@typescript-eslint/utils': 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) optionalDependencies: - typescript: 5.3.3 + typescript: 5.5.4 transitivePeerDependencies: - eslint - supports-color @@ -14505,7 +14505,7 @@ snapshots: typescript@5.3.3: {} - typescript@5.4.3: {} + typescript@5.5.4: {} ufo@1.4.0: {} @@ -14750,24 +14750,24 @@ snapshots: fsevents: 2.3.3 terser: 5.27.0 - vitepress@1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.3.3): + vitepress@1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.5.4): dependencies: '@docsearch/css': 3.6.1 '@docsearch/js': 3.6.1(@algolia/client-search@4.23.2)(search-insights@2.13.0) '@shikijs/core': 1.14.1 '@shikijs/transformers': 1.14.1 '@types/markdown-it': 14.1.2 - '@vitejs/plugin-vue': 5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.3.3)) + '@vitejs/plugin-vue': 5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) '@vue/devtools-api': 7.3.9 '@vue/shared': 3.4.38 - '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)) - '@vueuse/integrations': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(focus-trap@7.5.4)(vue@3.4.38(typescript@5.3.3)) + '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) + '@vueuse/integrations': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(focus-trap@7.5.4)(vue@3.4.38(typescript@5.5.4)) focus-trap: 7.5.4 mark.js: 8.11.1 minisearch: 7.1.0 shiki: 1.14.1 vite: 5.2.8(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.3.3) + vue: 3.4.38(typescript@5.5.4) optionalDependencies: postcss: 8.4.41 transitivePeerDependencies: @@ -14834,11 +14834,11 @@ snapshots: vm-browserify@1.1.2: {} - vue-demi@0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.3.3)))(vue@3.4.38(typescript@5.3.3)): + vue-demi@0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)): dependencies: - vue: 3.4.38(typescript@5.3.3) + vue: 3.4.38(typescript@5.5.4) optionalDependencies: - '@vue/composition-api': 1.7.2(vue@3.4.38(typescript@5.3.3)) + '@vue/composition-api': 1.7.2(vue@3.4.38(typescript@5.5.4)) vue-eslint-parser@9.4.3(eslint@9.9.1(jiti@1.21.0)): dependencies: @@ -14853,7 +14853,7 @@ snapshots: transitivePeerDependencies: - supports-color - vue-loader@16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.4.38(typescript@5.4.3))(webpack@4.47.0(webpack-cli@3.3.12)): + vue-loader@16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.4.38(typescript@5.5.4))(webpack@4.47.0(webpack-cli@3.3.12)): dependencies: chalk: 4.1.2 hash-sum: 2.0.0 @@ -14861,17 +14861,17 @@ snapshots: webpack: 4.47.0(webpack-cli@3.3.12) optionalDependencies: '@vue/compiler-sfc': 3.4.19 - vue: 3.4.38(typescript@5.4.3) + vue: 3.4.38(typescript@5.5.4) vue-router@4.2.5(vue@3.4.38(typescript@5.3.3)): dependencies: '@vue/devtools-api': 6.5.1 vue: 3.4.38(typescript@5.3.3) - vue-router@4.2.5(vue@3.4.38(typescript@5.4.3)): + vue-router@4.2.5(vue@3.4.38(typescript@5.5.4)): dependencies: '@vue/devtools-api': 6.5.1 - vue: 3.4.38(typescript@5.4.3) + vue: 3.4.38(typescript@5.5.4) vue-template-compiler@2.7.16: dependencies: @@ -14885,19 +14885,19 @@ snapshots: semver: 7.6.0 typescript: 5.3.3 - vue-tsc@1.8.27(typescript@5.4.3): + vue-tsc@1.8.27(typescript@5.5.4): dependencies: '@volar/typescript': 1.11.1 - '@vue/language-core': 1.8.27(typescript@5.4.3) + '@vue/language-core': 1.8.27(typescript@5.5.4) semver: 7.6.0 - typescript: 5.4.3 + typescript: 5.5.4 - vue-tsc@2.0.0(typescript@5.4.3): + vue-tsc@2.0.0(typescript@5.5.4): dependencies: '@volar/typescript': 2.1.0 - '@vue/language-core': 2.0.0(typescript@5.4.3) + '@vue/language-core': 2.0.0(typescript@5.5.4) semver: 7.6.0 - typescript: 5.4.3 + typescript: 5.5.4 vue@3.4.38(typescript@5.3.3): dependencies: @@ -14909,15 +14909,15 @@ snapshots: optionalDependencies: typescript: 5.3.3 - vue@3.4.38(typescript@5.4.3): + vue@3.4.38(typescript@5.5.4): dependencies: '@vue/compiler-dom': 3.4.38 '@vue/compiler-sfc': 3.4.38 '@vue/runtime-dom': 3.4.38 - '@vue/server-renderer': 3.4.38(vue@3.4.38(typescript@5.4.3)) + '@vue/server-renderer': 3.4.38(vue@3.4.38(typescript@5.5.4)) '@vue/shared': 3.4.38 optionalDependencies: - typescript: 5.4.3 + typescript: 5.5.4 w3c-xmlserializer@5.0.0: dependencies: diff --git a/rollup.config.mjs b/rollup.config.mjs index da40190ad..43bc88c32 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,12 +1,12 @@ -import { createRequire } from 'node:module' -import { fileURLToPath } from 'node:url' -import path from 'node:path' -import { promises as fs } from 'node:fs' -import ts from 'rollup-plugin-typescript2' -import replace from '@rollup/plugin-replace' import json from '@rollup/plugin-json' +import replace from '@rollup/plugin-replace' import terser from '@rollup/plugin-terser' +import { promises as fs } from 'node:fs' +import { createRequire } from 'node:module' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import pc from 'picocolors' +import ts from 'rollup-plugin-typescript2' if (!process.env.TARGET) { throw new Error('TARGET package must be specified via --environment flag.') @@ -154,7 +154,7 @@ function createConfig(format, _output, plugins = []) { declaration: shouldEmitDeclarations, declarationMap: shouldEmitDeclarations }, - exclude: ['**/test', 'test-dts', 'e2e', 'scripts', '*.config.ts'] + exclude: ['**/test', 'e2e', 'scripts', '*.config.ts'] } }) // we only need to check TS and generate declarations once for each build. diff --git a/test-dts/core-base/context.test-d.ts b/test-dts/core-base/context.test-d.ts deleted file mode 100644 index 989bfd5c6..000000000 --- a/test-dts/core-base/context.test-d.ts +++ /dev/null @@ -1,212 +0,0 @@ -import { expectType } from '../index' - -import { - CoreOptions, - createCoreContext, - Locale, - LocaleDetector, - LocaleParams, - PickupFallbackLocales, - SchemaParams -} from '../../packages/core-base/src' - -import type { - MyDatetimeScehma, - MyNumberSchema, - ResourceSchema -} from '../schema' - -// loose options -const looseOptions = { - locale: 'en', - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - } - }, - ja: { - bar: 'foo', - nest: { - bar: 'bar' - } - } - }, - datetimeFormats: { - 'en-US': { - short: {} - } - }, - numberFormats: { - 'ja-JP': { - currency: {} - } - } -} - -// strict options -const strictOptions = { - locale: 'en', - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] - }, - ja: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error2'] - } - } -} - -expectType(looseOptions) -expectType< - CoreOptions< - string, - SchemaParams< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - string - >, - LocaleParams<'en' | 'ja'> - > ->(strictOptions) - -// check loose context -const looseCtx = createCoreContext(looseOptions) -expectType<'en' | 'ja' | 'en-US' | 'ja-JP'>(looseCtx.locale) -expectType< - | 'en' - | 'ja' - | 'en-US' - | 'ja-JP' - | ('en' | 'ja' | 'en-US' | 'ja-JP')[] - | { - [x in string]: PickupFallbackLocales<['en' | 'ja' | 'en-US' | 'ja-JP']>[] - } - | false ->(looseCtx.fallbackLocale) -expectType<{ - en: { - foo: string - nest: { - bar: string - } - } - ja: { - bar: string - nest: { - bar: string - } - } -}>(looseCtx.messages) -expectType<{ 'en-US': { short: {} } }>(looseCtx.datetimeFormats) -expectType<{ 'ja-JP': { currency: {} } }>(looseCtx.numberFormats) - -// check strict context -const strictCtx = createCoreContext<[ResourceSchema], 'en' | 'ja'>( - strictOptions -) -expectType<'en' | 'ja'>(strictCtx.locale) -expectType< - | 'en' - | 'ja' - | ('en' | 'ja')[] - | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } - | false ->(strictCtx.fallbackLocale) -expectType<{ en: ResourceSchema; ja: ResourceSchema }>(strictCtx.messages) -expectType<{ en: {}; ja: {} }>(strictCtx.datetimeFormats) -expectType<{ en: {}; ja: {} }>(strictCtx.numberFormats) - -// check strict context with direct options -const strictDirectCtx = createCoreContext< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - { messages: 'en'; datetimeFormats: 'ja-JP' | 'zh'; numberFormats: 'ca' } ->({ - messages: { - en: { - foo: '', - nest: { - bar: '' - }, - errors: [''] - } - }, - datetimeFormats: { - zh: { - short: { - hour: 'numeric' - } - }, - 'ja-JP': { - short: { - hour: 'numeric' - } - } - }, - numberFormats: { - ca: { - currency: { style: 'symbol' } - } - } -}) -expectType<'en' | 'zh' | 'ca' | 'ja-JP'>(strictDirectCtx.locale) -expectType< - | 'en' - | 'zh' - | 'ca' - | 'ja-JP' - | ('en' | 'zh' | 'ca' | 'ja-JP')[] - | { [x in string]: PickupFallbackLocales<['en' | 'zh' | 'ca' | 'ja-JP']>[] } - | false ->(strictDirectCtx.fallbackLocale) -expectType<{ en: ResourceSchema }>(strictDirectCtx.messages) -expectType<{ zh: {}; 'ja-JP': { short: {} } }>(strictDirectCtx.datetimeFormats) -expectType<{ ca: { currency: {} } }>(strictDirectCtx.numberFormats) - -const nullCtx1 = createCoreContext({}) -expectType(nullCtx1.locale) -nullCtx1.locale = 'ja' -nullCtx1.locale = () => 'ja' -expectType< - | string - | string[] - | { [x in string]: PickupFallbackLocales<[string]>[] } - | false ->(nullCtx1.fallbackLocale) -nullCtx1.fallbackLocale = 'en' - -const nullCtx2 = createCoreContext({}) -const locale = nullCtx2.locale - -function detector1(arg: Locale): Locale { - return arg -} -// prettier-ignore -const detector: LocaleDetector = typeof locale === 'function' - ? detector1.bind(null, 'foo') - : typeof locale === 'string' - ? () => locale - : (arg: Locale) => arg -expect(detector) diff --git a/test-dts/core-base/datetime.test-d.ts b/test-dts/core-base/datetime.test-d.ts deleted file mode 100644 index b16efd068..000000000 --- a/test-dts/core-base/datetime.test-d.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { expectType } from '../index' - -import { createCoreContext, datetime } from '../../packages/core-base/src' - -const ctx = createCoreContext({ - locale: 'en-US', - datetimeFormats: { - 'en-US': { - short: { - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - timeZone: 'America/New_York' - } - } - } -}) - -const dt = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)) - -expectType(datetime(ctx, dt)) -expectType( - datetime(ctx, dt, { locale: 'en-US', key: 'short' }) -) -expectType( - datetime(ctx, dt, { key: 'short' }, 'en-US') -) -expectType( - datetime(ctx, dt, { key: 'short' }, { hourCycle: 'h24' }) -) -expectType( - datetime(ctx, dt, { key: 'short' }, 'en-US', { hourCycle: 'h24' }) -) diff --git a/test-dts/core-base/number.test-d.ts b/test-dts/core-base/number.test-d.ts deleted file mode 100644 index bd0ea9e47..000000000 --- a/test-dts/core-base/number.test-d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { expectType } from '../index' - -import { createCoreContext, number } from '../../packages/core-base/src' - -const ctx = createCoreContext({ - locale: 'en-US', - numberFormats: { - 'en-US': { - currency: { - style: 'currency', - currency: 'USD', - currencyDisplay: 'symbol' - } - } - } -}) - -expectType(number(ctx, 10100)) -expectType( - number(ctx, 10100, { locale: 'en-US', key: 'currency' }) -) -expectType( - number(ctx, 10100, { key: 'currency' }, 'en-US') -) -expectType( - number(ctx, 10100, { locale: 'en-US', key: 'currency' }, { unit: '' }) -) -expectType( - number(ctx, 10100, { key: 'currency' }, 'en-US', { unit: '' }) -) diff --git a/test-dts/core-base/runtime.test-d.ts b/test-dts/core-base/runtime.test-d.ts deleted file mode 100644 index 602990d03..000000000 --- a/test-dts/core-base/runtime.test-d.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { expectType } from '../index' - -import { MessageType } from '../../packages/core-base/src' - -/** - * Message Type - */ - -interface HaveToString { - toString: () => string -} -interface NotHaveToString { - foo: 1 -} -type HaveToStringTypeAlias = { - toString: (arg1: string, arg2: boolean) => string -} -type NotHaveToStringTypeAlias = { foo: 1 } -class HaveToStringClass { - toString(arg1: number, arg2: Date): string { - return arg1.toString() + arg2.toString() - } -} -class NotHaveToStringClass {} -enum NumberEnum { - One, - Two -} -enum StringEnum { - One = 'one', - Two = 'two' -} - -// OK -expectType('' as MessageType) // default -expectType('' as MessageType) // string type -expectType('' as MessageType<''>) // string literal -expectType(1 as MessageType) // number type -expectType<1>(1 as MessageType<1>) // number literal -expectType(new Date() as MessageType) // Date -// TODO: -// expectType(Object.create(null) as MessageType) // Object type -expectType<{ toString: () => '' }>( - Object.create({ toString: () => '' }) as MessageType<{ toString: () => '' }> -) // object literal -expectType>([0] as MessageType>) // Array type -expectType<[1, 2]>([1, 2] as MessageType<[1, 2]>) // Array literal -expectType<[number, string]>([1, ''] as MessageType<[number, string]>) // Tuple - -expectType((() => '') as MessageType) // Function -expectType(Symbol('foo') as MessageType) // Symbol -expectType({} as MessageType) // interface have toString -expectType({} as MessageType) // type alias have toString -expectType( - new HaveToStringClass() as MessageType -) // class have toString -expectType(NumberEnum.One as MessageType) // number enum -expectType(NumberEnum.Two as MessageType) // number enum field -expectType(StringEnum.One as MessageType) // string enum -expectType(StringEnum.Two as MessageType) // string enum field -expectType '' }>( - {} as MessageType '' }> -) - -// NG -expectType(Boolean(1) as MessageType) // boolean -expectType(true as MessageType) // true -expectType(false as MessageType) // false -expectType(null as MessageType) // null -expectType(undefined as MessageType) // undefined -expectType(0 as MessageType) // void -expectType('' as MessageType) // any -expectType('' as MessageType) // never -expectType('' as MessageType) // unknown -expectType({} as MessageType) // ts object -expectType({} as MessageType<{}>) // object empty -expectType(/foo/ as MessageType) // RegExp -expectType({ foo: 1 } as MessageType<{ foo: 1 }>) // object that cannot covert -expectType({} as MessageType) // interface does not have toString -expectType({} as MessageType) // type alias does not have toString -expectType( - new NotHaveToStringClass() as MessageType -) // class does not have toString - -/* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/test-dts/core-base/translate.test-d.ts b/test-dts/core-base/translate.test-d.ts deleted file mode 100644 index a551ae36d..000000000 --- a/test-dts/core-base/translate.test-d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { expectType } from '../index' - -import { createCoreContext, translate } from '../../packages/core-base/src' - -const ctx = createCoreContext({ - locale: 'en', - messages: { - en: { - hello: 'hello world!', - nest: { - world: 'hello nest world!' - } - } - } -}) - -expectType(translate(ctx, 'hello')) -expectType(translate(ctx, 'hello', 1)) -expectType( - translate(ctx, 'hello', 1, { locale: 'en', missingWarn: true }) -) -expectType(translate(ctx, 'hello', 'default msg')) -expectType( - translate(ctx, 'hello', 'default msg', { locale: 'en', plural: 2 }) -) -expectType(translate(ctx, 'hello', ['list'])) -expectType(translate(ctx, 'hello', ['list'], 1)) -expectType(translate(ctx, 'hello', ['list'], 'default msg')) -expectType(translate(ctx, 'hello', ['list'], { locale: 'en' })) -expectType(translate(ctx, 'hello', { name: 'dio' })) -expectType(translate(ctx, 'hello', { name: 'dio' }, 1)) -expectType( - translate(ctx, 'hello', { name: 'dio' }, 'default msg') -) -expectType( - translate( - ctx, - 'hello', - { name: 'dio' }, - { locale: 'en', resolvedMessage: true } - ) -) -expectType(translate(ctx, 'nest.world')) diff --git a/test-dts/index.d.ts b/test-dts/index.d.ts deleted file mode 100644 index bf48b7eb5..000000000 --- a/test-dts/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function describe(_name: string, _fn: () => void): void - -export function expectType(value: T): void -export function expectError(value: T): void -export function expectAssignable(value: T2): void diff --git a/test-dts/tsconfig.json b/test-dts/tsconfig.json deleted file mode 100644 index 500f6e301..000000000 --- a/test-dts/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "noEmit": true, - "declaration": true - }, - "exclude": ["../packages/*/test", "../packages/format-explorer/**"] -} diff --git a/test-dts/vue-i18n/components.test-d.tsx b/test-dts/vue-i18n/components.test-d.tsx deleted file mode 100644 index 3c9c8c7ed..000000000 --- a/test-dts/vue-i18n/components.test-d.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import 'vue/jsx' -import { expectError, expectType } from '..' -import { - DatetimeFormat, - NumberFormat, - Translation -} from '../../packages/vue-i18n-core/src/components' - -// @ts-expect-error missing keypath -expectError() -// @ts-expect-error invalid props -expectError() - -expectType() - -expectType() -expectType( - -) diff --git a/test-dts/vue-i18n/composer.test-d.ts b/test-dts/vue-i18n/composer.test-d.ts deleted file mode 100644 index aa561d527..000000000 --- a/test-dts/vue-i18n/composer.test-d.ts +++ /dev/null @@ -1,334 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { expectType } from '..' -import { - FallbackLocale, - Locale, - LocaleMessageValue, - LocaleParams, - PickupFallbackLocales, - SchemaParams -} from '../../packages/core-base/src' -import { - ComposerOptions, - createComposer -} from '../../packages/vue-i18n-core/src/composer' - -import type { - MyDatetimeScehma, - MyNumberSchema, - ResourceSchema -} from '../schema' - -declare module '../../packages/vue-i18n-core/src/composer' { - interface ComposerCustom { - localeCode: string[] - } -} - -// loose options -const looseOptions = { - locale: 'en', - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - } - }, - ja: { - bar: 'foo', - nest: { - bar: 'bar' - } - } - }, - datetimeFormats: { - 'en-US': { - short: {} - } - }, - numberFormats: { - 'ja-JP': { - currency: {} - } - } -} - -// strict options -const strictOptions = { - locale: 'en', - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] - }, - ja: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error2'] - } - } -} - -expectType(looseOptions) -expectType< - ComposerOptions< - SchemaParams< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - string - >, - LocaleParams<'en' | 'ja'> - > ->(strictOptions) - -// check loose composer -const looseComposer = createComposer(looseOptions) -expectType<'en' | 'ja' | 'en-US' | 'ja-JP'>(looseComposer.locale.value) -expectType< - | 'en' - | 'ja' - | 'en-US' - | 'ja-JP' - | ('en' | 'ja' | 'en-US' | 'ja-JP')[] - | { - [x in string]: PickupFallbackLocales<['en' | 'ja' | 'en-US' | 'ja-JP']>[] - } - | false ->(looseComposer.fallbackLocale.value) -expectType<{ - en: { - foo: string - nest: { - bar: string - } - } - ja: { - bar: string - nest: { - bar: string - } - } -}>(looseComposer.messages.value) -expectType<{ 'en-US': { short: {} } }>(looseComposer.datetimeFormats.value) -expectType<{ 'ja-JP': { currency: {} } }>(looseComposer.numberFormats.value) -expectType(looseComposer.t('nest.bar')) -expectType(looseComposer.t('nest', 1, { locale: 'en' })) -expectType(looseComposer.t('foo', 'default msg', { locale: 'en' })) -expectType(looseComposer.t('errors', [1], { plural: 1 })) -expectType(looseComposer.t('errors', [1], 1)) -expectType(looseComposer.t('errors', [1], 'default msg')) -expectType(looseComposer.t(1, { foo: 1 }, { locale: 'en' })) -expectType(looseComposer.t('nestt', { foo: 1 }, 'msg')) -expectType(looseComposer.te('errors', 'en')) -expectType<{ bar: string }>(looseComposer.tm('nest')) -expectType(looseComposer.tm('errors')) -expectType(looseComposer.rt('foo')) -expectType( - looseComposer.getLocaleMessage('en') -) -expectType<{ japan: string }>( - looseComposer.getLocaleMessage<{ japan: string }>('japan') -) -expectType(looseComposer.localeCode) -looseComposer.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -looseComposer.setLocaleMessage<{ dio: string }>('jojo', { - dio: 'The world!' -}) -looseComposer.mergeLocaleMessage('en', { - bar: 'foo' -}) -looseComposer.mergeLocaleMessage<{ dio: string }>('en', { - dio: 'The world!' -}) -expectType<(typeof looseComposer.datetimeFormats.value)['en-US']>( - looseComposer.getDateTimeFormat('en-US') -) -expectType<{ long: { hour: string } }>( - looseComposer.getLocaleMessage<{ long: { hour: string } }>('en-US') -) -looseComposer.setDateTimeFormat('ja-JP', { - short: { - hour: 'numeric' - } -}) -looseComposer.setDateTimeFormat<{ stop: { hour: string } }>('world', { - stop: { hour: 'infinity' } -}) -looseComposer.mergeDateTimeFormat('en-US', { - long: { hour: 'numeric' } -}) -looseComposer.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { - stop: { hour: 'infinity' } -}) -expectType<(typeof looseComposer.numberFormats.value)['ja-JP']>( - looseComposer.getNumberFormat('ja-JP') -) -expectType<{ weight: { unit: string } }>( - looseComposer.getNumberFormat<{ weight: { unit: string } }>('en-US') -) -looseComposer.setNumberFormat('en-US', { - currency: { - currecy: 'USD' - } -}) -looseComposer.setNumberFormat<{ echoes: { act: string } }>('stand', { - echoes: { act: '2' } -}) -looseComposer.mergeNumberFormat('ja-JP', { - weight: { - unit: 'kiro' - } -}) -looseComposer.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { - echoes: { act: '2' } -}) - -// check strict composer -const strictComposer = createComposer<[ResourceSchema], 'en' | 'ja'>( - strictOptions -) -expectType<'en' | 'ja'>(strictComposer.locale.value) -expectType< - | 'en' - | 'ja' - | ('en' | 'ja')[] - | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } - | false ->(strictComposer.fallbackLocale.value) -expectType<{ en: ResourceSchema; ja: ResourceSchema }>( - strictComposer.messages.value -) - -expectType<{ en: {}; ja: {} }>(strictComposer.datetimeFormats.value) - -expectType<{ en: {}; ja: {} }>(strictComposer.numberFormats.value) -expectType(strictComposer.t('nest.bar')) -expectType(strictComposer.t('nest', 1, { locale: 'en' })) -expectType(strictComposer.t('foo', 'default msg', { locale: 'en' })) -expectType(strictComposer.t('errors', [1], { plural: 1 })) -expectType(strictComposer.t('errors', [1], 1)) -expectType(strictComposer.t('errors', [1], 'default msg')) -expectType(strictComposer.t(1, { foo: 1 }, { locale: 'en' })) -expectType(strictComposer.t('nestt', { foo: 1 }, 'msg')) -expectType(strictComposer.te('errors', 'en')) -expectType<{ bar: string }>(strictComposer.tm('nest')) -expectType(strictComposer.tm('errors')) -expectType(strictComposer.rt('foo')) -expectType( - strictComposer.getLocaleMessage('en') -) -expectType<{ japan: string }>( - strictComposer.getLocaleMessage<{ japan: string }>('japan') -) -strictComposer.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -strictComposer.setLocaleMessage<{ dio: string }>('jojo', { - dio: 'The world!' -}) -strictComposer.mergeLocaleMessage('en', { - bar: 'foo' -}) -strictComposer.mergeLocaleMessage<{ dio: string }>('en', { - dio: 'The world!' -}) - -// check strict context with direct options -const strictDirectComposer = createComposer< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - { messages: 'en'; datetimeFormats: 'ja-JP' | 'zh'; numberFormats: 'ca' } ->({ - messages: { - en: { - foo: '', - nest: { - bar: '' - }, - errors: [''] - } - }, - datetimeFormats: { - zh: { - short: { - hour: 'numeric' - } - }, - 'ja-JP': { - short: { - hour: 'numeric' - } - } - }, - numberFormats: { - ca: { - currency: { style: 'symbol' } - } - } -}) -expectType<'en' | 'zh' | 'ca' | 'ja-JP'>(strictDirectComposer.locale.value) -expectType< - | 'en' - | 'zh' - | 'ca' - | 'ja-JP' - | ('en' | 'zh' | 'ca' | 'ja-JP')[] - | { [x in string]: PickupFallbackLocales<['en' | 'zh' | 'ca' | 'ja-JP']>[] } - | false ->(strictDirectComposer.fallbackLocale.value) -expectType<{ en: ResourceSchema }>(strictDirectComposer.messages.value) -expectType<{ zh: {}; 'ja-JP': { short: {} } }>( - strictDirectComposer.datetimeFormats.value -) -expectType<{ ca: { currency: {} } }>(strictDirectComposer.numberFormats.value) -expectType(strictDirectComposer.d(new Date())) -expectType(strictDirectComposer.d(new Date(), 'short', 'ja-JP')) -expectType( - strictDirectComposer.d(new Date(), { key: 'short', locale: 'zh' }) -) -expectType(strictDirectComposer.d(new Date(), 'custom' as any)) -expectType(strictDirectComposer.n(1)) -expectType(strictDirectComposer.n(1, 'currency', 'zh')) -expectType(strictDirectComposer.n(1, { key: 'currency', locale: 'en' })) -expectType(strictDirectComposer.n(1, 'custom' as any)) - -// const noOptionsComposer = createComposer({ missingWarn: true }) -const noOptionsComposer = createComposer({ locale: 'en' }) -expectType(noOptionsComposer.locale.value) -expectType(noOptionsComposer.fallbackLocale.value) - -const nullComposer = createComposer({}) -expectType(nullComposer.locale.value) -nullComposer.locale.value = 'en' -expectType(nullComposer.fallbackLocale.value) -nullComposer.fallbackLocale.value = 'fr' - -/* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/test-dts/vue-i18n/i18n.test-d.ts b/test-dts/vue-i18n/i18n.test-d.ts deleted file mode 100644 index c2ea5383f..000000000 --- a/test-dts/vue-i18n/i18n.test-d.ts +++ /dev/null @@ -1,522 +0,0 @@ -import { expectType } from '..' -import { - LocaleMessageValue, - LocaleParams, - PickupFallbackLocales, - SchemaParams -} from '../../packages/core-base/src' -import * as vueI18n from '../../packages/vue-i18n-core/src/i18n' -import { - createI18n, - I18nOptions, - useI18n, - UseI18nOptions -} from '../../packages/vue-i18n-core/src/i18n' - -import type { - MyDatetimeScehma, - MyNumberSchema, - ResourceSchema -} from '../schema' - -// loose options -const looseOptions = { - locale: 'en', - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - } - }, - ja: { - bar: 'foo', - nest: { - bar: 'bar' - } - } - }, - datetimeFormats: { - 'en-US': { - short: {} - } - }, - numberFormats: { - 'ja-JP': { - currency: {} - } - } -} - -// strict options -const strictOptions = { - locale: 'en', - legacy: false, - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] - }, - ja: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error2'] - } - } -} - -expectType(looseOptions) -expectType< - UseI18nOptions< - SchemaParams< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - string - >, - LocaleParams<'en' | 'ja'> - > ->(strictOptions) - -// check loose composer -const looseComposer = useI18n(looseOptions) -expectType<'en' | 'ja' | 'en-US' | 'ja-JP'>(looseComposer.locale.value) -expectType< - | 'en' - | 'ja' - | 'en-US' - | 'ja-JP' - | ('en' | 'ja' | 'en-US' | 'ja-JP')[] - | { - [x in string]: PickupFallbackLocales<['en' | 'ja' | 'en-US' | 'ja-JP']>[] - } - | false ->(looseComposer.fallbackLocale.value) -expectType<{ - en: { - foo: string - nest: { - bar: string - } - } - ja: { - bar: string - nest: { - bar: string - } - } -}>(looseComposer.messages.value) -expectType<{ 'en-US': { short: {} } }>(looseComposer.datetimeFormats.value) -expectType<{ 'ja-JP': { currency: {} } }>(looseComposer.numberFormats.value) -expectType(looseComposer.t('nest.bar')) -expectType(looseComposer.t('nest', 1, { locale: 'en' })) -expectType(looseComposer.t('foo', 'default msg', { locale: 'en' })) -expectType(looseComposer.t('errors', [1], { plural: 1 })) -expectType(looseComposer.t('errors', [1], 1)) -expectType(looseComposer.t('errors', [1], 'default msg')) -expectType(looseComposer.t(1, { foo: 1 }, { locale: 'en' })) -expectType(looseComposer.t('nestt', { foo: 1 }, 'msg')) -expectType(looseComposer.te('errors', 'en')) -expectType<{ bar: string }>(looseComposer.tm('nest')) -expectType(looseComposer.tm('errors')) -expectType(looseComposer.rt('foo')) -expectType( - looseComposer.getLocaleMessage('en') -) -expectType<{ japan: string }>( - looseComposer.getLocaleMessage<{ japan: string }>('japan') -) -looseComposer.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -looseComposer.setLocaleMessage<{ dio: string }>('jojo', { - dio: 'The world!' -}) -looseComposer.mergeLocaleMessage('en', { - bar: 'foo' -}) -looseComposer.mergeLocaleMessage<{ dio: string }>('en', { - dio: 'The world!' -}) -expectType<(typeof looseComposer.datetimeFormats.value)['en-US']>( - looseComposer.getDateTimeFormat('en-US') -) -expectType<{ long: { hour: string } }>( - looseComposer.getLocaleMessage<{ long: { hour: string } }>('en-US') -) -looseComposer.setDateTimeFormat('ja-JP', { - short: { - hour: 'numeric' - } -}) -looseComposer.setDateTimeFormat<{ stop: { hour: string } }>('world', { - stop: { hour: 'infinity' } -}) -looseComposer.mergeDateTimeFormat('en-US', { - long: { hour: 'numeric' } -}) -looseComposer.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { - stop: { hour: 'infinity' } -}) -expectType<(typeof looseComposer.numberFormats.value)['ja-JP']>( - looseComposer.getNumberFormat('ja-JP') -) -expectType<{ weight: { unit: string } }>( - looseComposer.getNumberFormat<{ weight: { unit: string } }>('en-US') -) -looseComposer.setNumberFormat('en-US', { - currency: { - currecy: 'USD' - } -}) -looseComposer.setNumberFormat<{ echoes: { act: string } }>('stand', { - echoes: { act: '2' } -}) -looseComposer.mergeNumberFormat('ja-JP', { - weight: { - unit: 'kiro' - } -}) -looseComposer.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { - echoes: { act: '2' } -}) - -// check strict composer -const strictComposer = useI18n<[ResourceSchema], 'en' | 'ja'>(strictOptions) -expectType<'en' | 'ja'>(strictComposer.locale.value) -expectType< - | 'en' - | 'ja' - | ('en' | 'ja')[] - | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } - | false ->(strictComposer.fallbackLocale.value) -expectType<{ en: ResourceSchema; ja: ResourceSchema }>( - strictComposer.messages.value -) - -expectType<{ en: {}; ja: {} }>(strictComposer.datetimeFormats.value) - -expectType<{ en: {}; ja: {} }>(strictComposer.numberFormats.value) -expectType(strictComposer.t('nest.bar')) -expectType(strictComposer.t('nest', 1, { locale: 'en' })) -expectType(strictComposer.t('foo', 'default msg', { locale: 'en' })) -expectType(strictComposer.t('errors', [1], { plural: 1 })) -expectType(strictComposer.t('errors', [1], 1)) -expectType(strictComposer.t('errors', [1], 'default msg')) -expectType(strictComposer.t(1, { foo: 1 }, { locale: 'en' })) -expectType(strictComposer.t('nestt', { foo: 1 }, 'msg')) -expectType(strictComposer.te('errors', 'en')) -expectType<{ bar: string }>(strictComposer.tm('nest')) -expectType(strictComposer.tm('errors')) -expectType(strictComposer.rt('foo')) -expectType( - strictComposer.getLocaleMessage('en') -) -expectType<{ japan: string }>( - strictComposer.getLocaleMessage<{ japan: string }>('japan') -) -strictComposer.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -strictComposer.setLocaleMessage<{ dio: string }>('jojo', { - dio: 'The world!' -}) -strictComposer.mergeLocaleMessage('en', { - bar: 'foo' -}) -strictComposer.mergeLocaleMessage<{ dio: string }>('en', { - dio: 'The world!' -}) - -// not local scope -const globalComposer = useI18n<[ResourceSchema], 'en' | 'ja'>({ - inheritLocale: true, - useScope: 'global' -}) -expect(globalComposer.t('nest.bar', { foo: 1 }, { locale: 'ja' })) -expect<'en' | 'ja'>(globalComposer.locale.value) - -// no annotation -const localComposer = useI18n({ - useScope: 'local' -}) -expect(localComposer.locale.value) - -expectType(looseOptions) -expectType< - I18nOptions< - SchemaParams< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - string - >, - LocaleParams<'en' | 'ja'> - > ->(strictOptions) -// check loose i18n composer -const looseI18nComposer = createI18n({ - ...looseOptions, - legacy: false -}).global -expectType<'en' | 'ja' | 'en-US' | 'ja-JP'>(looseI18nComposer.locale.value) -expectType<{ - en: { - foo: string - nest: { - bar: string - } - } - ja: { - bar: string - nest: { - bar: string - } - } -}>(looseI18nComposer.messages.value) - -// check loose i18n -const looseI18n = createI18n(looseOptions).global -expectType<'en' | 'ja' | 'en-US' | 'ja-JP'>(looseI18n.locale) -expectType< - | 'en' - | 'ja' - | 'en-US' - | 'ja-JP' - | ('en' | 'ja' | 'en-US' | 'ja-JP')[] - | { - [x in string]: PickupFallbackLocales<['en' | 'ja' | 'en-US' | 'ja-JP']>[] - } - | false ->(looseI18n.fallbackLocale) -expectType<{ - en: { - foo: string - nest: { - bar: string - } - } - ja: { - bar: string - nest: { - bar: string - } - } -}>(looseI18n.messages) - -expectType<{ 'en-US': { short: {} } }>(looseI18n.datetimeFormats) - -expectType<{ 'ja-JP': { currency: {} } }>(looseI18n.numberFormats) -expectType(looseI18n.t('nest.bar')) -expectType(looseI18n.t('nest', 'en')) -expectType(looseI18n.t('foo', [1])) -expectType(looseI18n.t('nest', { foo: 1 })) -expectType(looseI18n.tc('nest')) -expectType(looseI18n.tc('bar', 'en')) -expectType(looseI18n.tc('bar', ['foo'])) -expectType(looseI18n.tc('bar', { foo: 'foo' })) -expectType(looseI18n.tc('nest.bar', 1)) -expectType(looseI18n.tc('nest.bar', 1, ['bar'])) -expectType(looseI18n.tc('nest.bar', 1, { foo: 'bar' })) -expectType(looseI18n.te('errors', 'en')) -expectType<{ bar: string }>(looseI18n.tm('nest')) -expectType(looseI18n.tm('errors')) -expectType(looseI18n.rt('foo')) -expectType(looseI18n.getLocaleMessage('en')) -expectType<{ japan: string }>( - looseI18n.getLocaleMessage<{ japan: string }>('japan') -) -looseI18n.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -looseI18n.setLocaleMessage<{ dio: string }>('jojo', { - dio: 'The world!' -}) -looseI18n.mergeLocaleMessage('en', { - bar: 'foo' -}) -looseI18n.mergeLocaleMessage<{ dio: string }>('en', { - dio: 'The world!' -}) -expectType<(typeof looseI18n.datetimeFormats)['en-US']>( - looseI18n.getDateTimeFormat('en-US') -) -expectType<{ long: { hour: string } }>( - looseI18n.getLocaleMessage<{ long: { hour: string } }>('en-US') -) -looseI18n.setDateTimeFormat('ja-JP', { - short: { - hour: 'numeric' - } -}) -looseI18n.setDateTimeFormat<{ stop: { hour: string } }>('world', { - stop: { hour: 'infinity' } -}) -looseI18n.mergeDateTimeFormat('en-US', { - long: { hour: 'numeric' } -}) -looseI18n.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { - stop: { hour: 'infinity' } -}) -expectType<(typeof looseI18n.numberFormats)['ja-JP']>( - looseI18n.getNumberFormat('ja-JP') -) -expectType<{ weight: { unit: string } }>( - looseI18n.getNumberFormat<{ weight: { unit: string } }>('en-US') -) -looseI18n.setNumberFormat('en-US', { - currency: { - currecy: 'USD' - } -}) -looseI18n.setNumberFormat<{ echoes: { act: string } }>('stand', { - echoes: { act: '2' } -}) -looseI18n.mergeNumberFormat('ja-JP', { - weight: { - unit: 'kiro' - } -}) -looseI18n.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { - echoes: { act: '2' } -}) - -// check strict i18n -const strictI18n = createI18n<[ResourceSchema], 'en' | 'ja', false>( - strictOptions -).global -expectType<'en' | 'ja'>(strictI18n.locale.value) -expectType< - | 'en' - | 'ja' - | ('en' | 'ja')[] - | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } - | false ->(strictI18n.fallbackLocale.value) -expectType<{ en: ResourceSchema; ja: ResourceSchema }>( - strictI18n.messages.value -) - -expectType<{ en: {}; ja: {} }>(strictI18n.datetimeFormats.value) - -expectType<{ en: {}; ja: {} }>(strictI18n.numberFormats.value) -expectType(strictI18n.t('nest.bar')) -expectType(strictI18n.t('nest', 1, { locale: 'en' })) -expectType(strictI18n.t('foo', 'default msg', { locale: 'en' })) -expectType(strictI18n.t('errors', [1], { plural: 1 })) -expectType(strictI18n.t('errors', [1], 1)) -expectType(strictI18n.t('errors', [1], 'default msg')) -expectType(strictI18n.t(1, { foo: 1 }, { locale: 'en' })) -expectType(strictI18n.t('nestt', { foo: 1 }, 'msg')) -expectType(strictI18n.te('errors', 'en')) -expectType<{ bar: string }>(strictI18n.tm('nest')) -expectType(strictI18n.tm('errors')) -expectType(strictI18n.rt('foo')) -expectType( - strictI18n.getLocaleMessage('en') -) -expectType<{ japan: string }>( - strictI18n.getLocaleMessage<{ japan: string }>('japan') -) -strictI18n.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -strictI18n.setLocaleMessage<{ dio: string }>('jojo', { - dio: 'The world!' -}) -strictI18n.mergeLocaleMessage('en', { - bar: 'foo' -}) -strictI18n.mergeLocaleMessage<{ dio: string }>('en', { - dio: 'The world!' -}) - -// check strict with direct i18n options -const strictDirectI18n = createI18n< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - { messages: 'en'; datetimeFormats: 'ja-JP' | 'zh'; numberFormats: 'ca' }, - false ->({ - messages: { - en: { - foo: '', - nest: { - bar: '' - }, - errors: [''] - } - }, - datetimeFormats: { - zh: { - short: { - hour: 'numeric' - } - }, - 'ja-JP': { - short: { - hour: 'numeric' - } - } - }, - numberFormats: { - ca: { - currency: { style: 'symbol' } - } - } -}).global -expectType<'en' | 'zh' | 'ca' | 'ja-JP'>(strictDirectI18n.locale.value) -expectType< - | 'en' - | 'zh' - | 'ca' - | 'ja-JP' - | ('en' | 'zh' | 'ca' | 'ja-JP')[] - | { [x in string]: PickupFallbackLocales<['en' | 'zh' | 'ca' | 'ja-JP']>[] } - | false ->(strictDirectI18n.fallbackLocale.value) -expectType<{ en: ResourceSchema }>(strictDirectI18n.messages.value) -expectType<{ zh: {}; 'ja-JP': { short: {} } }>( - strictDirectI18n.datetimeFormats.value -) -expectType<{ ca: { currency: {} } }>(strictDirectI18n.numberFormats.value) - -// allow mocking -vi.spyOn(vueI18n, 'useI18n').mockReturnValue(>{ - t: (key: string) => `{{${key}}}` -}) diff --git a/test-dts/vue-i18n/legacy.test-d.ts b/test-dts/vue-i18n/legacy.test-d.ts deleted file mode 100644 index bff3c3db6..000000000 --- a/test-dts/vue-i18n/legacy.test-d.ts +++ /dev/null @@ -1,250 +0,0 @@ -import { expectType } from '..' -import { - FallbackLocale, - Locale, - LocaleMessageValue, - LocaleParams, - PickupFallbackLocales, - SchemaParams -} from '../../packages/core-base/src' -import { - VueI18nOptions, - createVueI18n -} from '../../packages/vue-i18n-core/src/legacy' - -import type { - MyDatetimeScehma, - MyNumberSchema, - ResourceSchema -} from '../schema' - -// loose options -const looseOptions = { - locale: 'en', - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] - }, - ja: { - bar: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error2'] - } - }, - datetimeFormats: { - 'en-US': { - short: {} - } - }, - numberFormats: { - 'ja-JP': { - currency: {} - } - } -} - -// strict options -const strictOptions = { - locale: 'en', - fallbackLocale: { - ja: ['en'] - }, - messages: { - en: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] - }, - ja: { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error2'] - } - } -} - -expectType(looseOptions) -expectType< - VueI18nOptions< - SchemaParams< - { - message: ResourceSchema - datetime: MyDatetimeScehma - number: MyNumberSchema - }, - string - >, - LocaleParams<'en' | 'ja'> - > ->(strictOptions) - -// check loose VueI18n -const looseVueI18n = createVueI18n(looseOptions) -expectType<'en' | 'ja' | 'en-US' | 'ja-JP'>(looseVueI18n.locale) -expectType< - | 'en' - | 'ja' - | 'en-US' - | 'ja-JP' - | ('en' | 'ja' | 'en-US' | 'ja-JP')[] - | { - [x in string]: PickupFallbackLocales<['en' | 'ja' | 'en-US' | 'ja-JP']>[] - } - | false ->(looseVueI18n.fallbackLocale) -expectType<{ - en: { - foo: string - nest: { - bar: string - } - } - ja: { - bar: string - nest: { - bar: string - } - } -}>(looseVueI18n.messages) -expectType<{ 'en-US': { short: {} } }>(looseVueI18n.datetimeFormats) -expectType<{ 'ja-JP': { currency: {} } }>(looseVueI18n.numberFormats) -expectType(looseVueI18n.t('nest.bar')) -expectType(looseVueI18n.t('nest', 'en')) -expectType(looseVueI18n.t('foo', [1])) -expectType(looseVueI18n.t('nest', { foo: 1 })) -expectType(looseVueI18n.tc('nest')) -expectType(looseVueI18n.tc('bar', 'en')) -expectType(looseVueI18n.tc('bar', ['foo'])) -expectType(looseVueI18n.tc('bar', { foo: 'foo' })) -expectType(looseVueI18n.tc('nest.bar', 1)) -expectType(looseVueI18n.tc('nest.bar', 1, ['bar'])) -expectType(looseVueI18n.tc('nest.bar', 1, { foo: 'bar' })) -expectType(looseVueI18n.te('errors', 'en')) -expectType<{ bar: string }>(looseVueI18n.tm('nest')) -expectType>(looseVueI18n.tm('errors')) -expectType(looseVueI18n.rt('foo')) -expectType(looseVueI18n.getLocaleMessage('en')) -expectType<{ japan: string }>( - looseVueI18n.getLocaleMessage<{ japan: string }>('japan') -) -looseVueI18n.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -looseVueI18n.setLocaleMessage<{ dio: string }>('jojo', { dio: 'dio' }) -looseVueI18n.mergeLocaleMessage('en', { - bar: 'foo' -}) -looseVueI18n.setDateTimeFormat('ja-JP', { - short: { - hour: 'numeric' - } -}) -looseVueI18n.setDateTimeFormat<{ stop: { hour: string } }>('world', { - stop: { hour: 'infinity' } -}) -looseVueI18n.mergeDateTimeFormat('en-US', { - long: { hour: 'numeric' } -}) -looseVueI18n.mergeDateTimeFormat<{ stop: { hour: string } }>('en-US', { - stop: { hour: 'infinity' } -}) -expectType<(typeof looseVueI18n.numberFormats)['ja-JP']>( - looseVueI18n.getNumberFormat('ja-JP') -) -expectType<{ weight: { unit: string } }>( - looseVueI18n.getNumberFormat<{ weight: { unit: string } }>('en-US') -) -looseVueI18n.setNumberFormat('en-US', { - currency: { - currecy: 'USD' - } -}) -looseVueI18n.setNumberFormat<{ echoes: { act: string } }>('stand', { - echoes: { act: '2' } -}) -looseVueI18n.mergeNumberFormat('ja-JP', { - weight: { - unit: 'kiro' - } -}) -looseVueI18n.mergeNumberFormat<{ echoes: { act: string } }>('ja-JP', { - echoes: { act: '2' } -}) - -// check strict VueI18n -const strictVueI18n = createVueI18n<[ResourceSchema], 'en' | 'ja'>( - strictOptions -) -expectType<'en' | 'ja'>(strictVueI18n.locale) -expectType< - | 'en' - | 'ja' - | ('en' | 'ja')[] - | { [x in string]: PickupFallbackLocales<['en' | 'ja']>[] } - | false ->(strictVueI18n.fallbackLocale) -expectType<{ en: ResourceSchema; ja: ResourceSchema }>(strictVueI18n.messages) - -expectType<{ en: {}; ja: {} }>(strictVueI18n.datetimeFormats) - -expectType<{ en: {}; ja: {} }>(strictVueI18n.numberFormats) -expectType(strictVueI18n.t('nest.bar')) -expectType(strictVueI18n.t('nest', 'en')) -expectType(strictVueI18n.t('foo', [1])) -expectType(strictVueI18n.t('nest', { foo: 1 })) -expectType(strictVueI18n.tc('nest')) -expectType(strictVueI18n.tc('bar', 'en')) -expectType(strictVueI18n.tc('bar', ['foo'])) -expectType(strictVueI18n.tc('bar', { foo: 'foo' })) -expectType(strictVueI18n.tc('nest.bar', 1)) -expectType(strictVueI18n.tc('nest.bar', 1, ['bar'])) -expectType(strictVueI18n.tc('nest.bar', 1, { foo: 'bar' })) -expectType(strictVueI18n.te('errors', 'en')) -expectType<{ bar: string }>(strictVueI18n.tm('nest')) -expectType>(strictVueI18n.tm('errors')) -expectType(strictVueI18n.rt('foo')) -expectType( - strictVueI18n.getLocaleMessage('en') -) -expectType<{ japan: string }>( - strictVueI18n.getLocaleMessage<{ japan: string }>('japan') -) -strictVueI18n.setLocaleMessage('en', { - foo: 'foo', - nest: { - bar: 'bar' - }, - errors: ['error1'] -}) -strictVueI18n.setLocaleMessage<{ dio: string }>('jojo', { - dio: 'The world!' -}) -strictVueI18n.mergeLocaleMessage('en', { - bar: 'foo' -}) -strictVueI18n.mergeLocaleMessage<{ dio: string }>('en', { - dio: 'The world!' -}) - -const nullVueI18n = createVueI18n({}) -expectType(nullVueI18n.locale) -nullVueI18n.locale = 'en' -expectType(nullVueI18n.fallbackLocale) -nullVueI18n.fallbackLocale = 'fr' diff --git a/tsconfig.json b/tsconfig.json index 1c016710e..5b8c3cde8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -74,7 +74,6 @@ "packages/*/src", "packages/*/test", "packages/*/*.config.ts", - "test-dts", "scripts", "e2e", "shim.d.ts", From 539bb83cc4469073fd72f014e122b884d161f599 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Thu, 5 Sep 2024 17:25:43 +0900 Subject: [PATCH 2/3] chore: update lock file --- pnpm-lock.yaml | 311 +++++++++---------------------------------------- 1 file changed, 56 insertions(+), 255 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e23fb7bf1..a6ef6f23b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -236,22 +236,13 @@ importers: version: 8.4.0(eslint@9.9.1(jiti@1.21.0))(typescript@5.5.4) vitepress: specifier: 1.3.4 -<<<<<<< HEAD - version: 1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.5.4) -======= - version: 1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.3.3) ->>>>>>> master + version: 1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(postcss@8.4.45)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.5.4) vitest: specifier: ^2.0.4 version: 2.0.4(@types/node@22.5.3)(jsdom@24.0.0)(terser@5.27.0) vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.3.3) ->>>>>>> master + version: 3.5.1(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:packages/vue-i18n @@ -336,31 +327,18 @@ importers: examples/lazy-loading/webpack: dependencies: vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) ->>>>>>> master + version: 3.5.1(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:../../../packages/vue-i18n vue-router: specifier: ^4.0.5 -<<<<<<< HEAD - version: 4.2.5(vue@3.4.38(typescript@5.5.4)) - devDependencies: - '@intlify/vue-i18n-loader': - specifier: ^3.2.0 - version: 3.3.0(vue@3.4.38(typescript@5.5.4)) -======= - version: 4.2.5(vue@3.5.1(typescript@5.4.3)) + version: 4.2.5(vue@3.5.1(typescript@5.5.4)) devDependencies: '@intlify/vue-i18n-loader': specifier: ^3.2.0 - version: 3.3.0(vue@3.5.1(typescript@5.4.3)) ->>>>>>> master + version: 3.3.0(vue@3.5.1(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.2.0 version: 3.4.19 @@ -378,11 +356,7 @@ importers: version: 4.1.1(file-loader@6.2.0(webpack@4.47.0(webpack-cli@3.3.12)))(webpack@4.47.0(webpack-cli@3.3.12)) vue-loader: specifier: ^16.8.0 -<<<<<<< HEAD - version: 16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.4.38(typescript@5.5.4))(webpack@4.47.0(webpack-cli@3.3.12)) -======= - version: 16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.5.1(typescript@5.4.3))(webpack@4.47.0(webpack-cli@3.3.12)) ->>>>>>> master + version: 16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.5.1(typescript@5.5.4))(webpack@4.47.0(webpack-cli@3.3.12)) webpack: specifier: ^4.44.0 version: 4.47.0(webpack-cli@3.3.12) @@ -425,30 +399,18 @@ importers: examples/tsx: dependencies: vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) ->>>>>>> master + version: 3.5.1(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:../../packages/vue-i18n devDependencies: '@vitejs/plugin-vue': specifier: ^4.2.3 -<<<<<<< HEAD - version: 4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) - '@vitejs/plugin-vue-jsx': - specifier: ^3.0.2 - version: 3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) -======= - version: 4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3)) + version: 4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4)) '@vitejs/plugin-vue-jsx': specifier: ^3.0.2 - version: 3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3)) ->>>>>>> master + version: 3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -574,21 +536,12 @@ importers: specifier: ^1.0.2 version: 1.0.2 vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) - devDependencies: - '@vitejs/plugin-vue': - specifier: ^5.0.0 - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) + version: 3.5.1(typescript@5.5.4) devDependencies: '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3)) ->>>>>>> master + version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -620,13 +573,8 @@ importers: specifier: ^6.5.0 version: 6.5.1 vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) ->>>>>>> master + version: 3.5.1(typescript@5.5.4) devDependencies: '@intlify/devtools-types': specifier: workspace:* @@ -650,21 +598,12 @@ importers: specifier: workspace:* version: link:../petite-vue-i18n vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) - devDependencies: - '@vitejs/plugin-vue': - specifier: ^5.0.0 - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) + version: 3.5.1(typescript@5.5.4) devDependencies: '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3)) ->>>>>>> master + version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -678,24 +617,15 @@ importers: packages/size-check-vue-i18n: dependencies: vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) ->>>>>>> master + version: 3.5.1(typescript@5.5.4) vue-i18n: specifier: workspace:* version: link:../vue-i18n devDependencies: '@vitejs/plugin-vue': specifier: ^5.0.0 -<<<<<<< HEAD - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) -======= - version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3)) ->>>>>>> master + version: 5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4)) '@vue/compiler-sfc': specifier: ^3.3.4 version: 3.4.19 @@ -718,13 +648,8 @@ importers: specifier: ^6.5.0 version: 6.5.1 vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) ->>>>>>> master + version: 3.5.1(typescript@5.5.4) devDependencies: '@intlify/devtools-types': specifier: workspace:* @@ -742,13 +667,8 @@ importers: specifier: ^6.5.0 version: 6.5.1 vue: -<<<<<<< HEAD - specifier: 3.4.38 - version: 3.4.38(typescript@5.5.4) -======= specifier: 3.5.1 - version: 3.5.1(typescript@5.4.3) ->>>>>>> master + version: 3.5.1(typescript@5.5.4) devDependencies: '@intlify/devtools-types': specifier: workspace:* @@ -8194,22 +8114,14 @@ snapshots: '@intlify/shared': 9.13.1 optional: true -<<<<<<< HEAD - '@intlify/vue-i18n-loader@3.3.0(vue@3.4.38(typescript@5.5.4))': -======= - '@intlify/vue-i18n-loader@3.3.0(vue@3.5.1(typescript@5.4.3))': ->>>>>>> master + '@intlify/vue-i18n-loader@3.3.0(vue@3.5.1(typescript@5.5.4))': dependencies: '@intlify/bundle-utils': 1.0.0 '@intlify/shared': 9.11.0 js-yaml: 4.1.0 json5: 2.2.3 loader-utils: 2.0.4 -<<<<<<< HEAD - vue: 3.4.38(typescript@5.5.4) -======= - vue: 3.5.1(typescript@5.4.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) '@isaacs/cliui@8.0.2': dependencies: @@ -9101,21 +9013,13 @@ snapshots: '@typescript-eslint/types': 8.4.0 eslint-visitor-keys: 3.4.3 -<<<<<<< HEAD - '@vitejs/plugin-vue-jsx@3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': -======= - '@vitejs/plugin-vue-jsx@3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3))': ->>>>>>> master + '@vitejs/plugin-vue-jsx@3.1.0(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4))': dependencies: '@babel/core': 7.23.9 '@babel/plugin-transform-typescript': 7.23.6(@babel/core@7.23.9) '@vue/babel-plugin-jsx': 1.2.1(@babel/core@7.23.9) vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) -<<<<<<< HEAD - vue: 3.4.38(typescript@5.5.4) -======= - vue: 3.5.1(typescript@5.4.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) transitivePeerDependencies: - supports-color @@ -9124,37 +9028,20 @@ snapshots: vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) vue: 3.5.1(typescript@5.3.3) -<<<<<<< HEAD - '@vitejs/plugin-vue@4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': + '@vitejs/plugin-vue@4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4))': dependencies: vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.5.4) + vue: 3.5.1(typescript@5.5.4) - '@vitejs/plugin-vue@5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': + '@vitejs/plugin-vue@5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4))': dependencies: vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.5.4) + vue: 3.5.1(typescript@5.5.4) - '@vitejs/plugin-vue@5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4))': + '@vitejs/plugin-vue@5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4))': dependencies: vite: 5.2.8(@types/node@22.5.3)(terser@5.27.0) - vue: 3.4.38(typescript@5.5.4) -======= - '@vitejs/plugin-vue@4.6.2(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3))': - dependencies: - vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) - vue: 3.5.1(typescript@5.4.3) - - '@vitejs/plugin-vue@5.0.4(vite@5.1.7(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.4.3))': - dependencies: - vite: 5.1.7(@types/node@22.5.3)(terser@5.27.0) - vue: 3.5.1(typescript@5.4.3) - - '@vitejs/plugin-vue@5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.3.3))': - dependencies: - vite: 5.2.8(@types/node@22.5.3)(terser@5.27.0) - vue: 3.5.1(typescript@5.3.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) '@vitest/coverage-v8@2.0.0(vitest@2.0.4(@types/node@22.5.3)(jsdom@24.0.0)(terser@5.27.0))': dependencies: @@ -9348,20 +9235,14 @@ snapshots: '@vue/compiler-dom': 3.4.38 '@vue/shared': 3.4.38 -<<<<<<< HEAD - '@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4))': - dependencies: - vue: 3.4.38(typescript@5.5.4) -======= '@vue/compiler-ssr@3.5.1': dependencies: '@vue/compiler-dom': 3.5.1 '@vue/shared': 3.5.1 - '@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3))': + '@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4))': dependencies: - vue: 3.5.1(typescript@5.3.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) optional: true '@vue/devtools-api@6.5.1': {} @@ -9446,58 +9327,33 @@ snapshots: '@vue/shared': 3.5.1 vue: 3.5.1(typescript@5.3.3) -<<<<<<< HEAD - '@vue/server-renderer@3.4.38(vue@3.4.38(typescript@5.5.4))': - dependencies: - '@vue/compiler-ssr': 3.4.38 - '@vue/shared': 3.4.38 - vue: 3.4.38(typescript@5.5.4) -======= - '@vue/server-renderer@3.5.1(vue@3.5.1(typescript@5.4.3))': + '@vue/server-renderer@3.5.1(vue@3.5.1(typescript@5.5.4))': dependencies: '@vue/compiler-ssr': 3.5.1 '@vue/shared': 3.5.1 - vue: 3.5.1(typescript@5.4.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) '@vue/shared@3.4.19': {} '@vue/shared@3.4.38': {} -<<<<<<< HEAD - '@vueuse/core@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4))': - dependencies: - '@types/web-bluetooth': 0.0.20 - '@vueuse/metadata': 11.0.3 - '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) -======= '@vue/shared@3.5.1': {} - '@vueuse/core@11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3))': + '@vueuse/core@11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4))': dependencies: '@types/web-bluetooth': 0.0.20 '@vueuse/metadata': 11.0.3 - '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)) - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)) ->>>>>>> master + '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)) transitivePeerDependencies: - '@vue/composition-api' - vue -<<<<<<< HEAD - '@vueuse/integrations@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(focus-trap@7.5.4)(vue@3.4.38(typescript@5.5.4))': + '@vueuse/integrations@11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(focus-trap@7.5.4)(vue@3.5.1(typescript@5.5.4))': dependencies: - '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) - '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) -======= - '@vueuse/integrations@11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(focus-trap@7.5.4)(vue@3.5.1(typescript@5.3.3))': - dependencies: - '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)) - '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)) - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)) ->>>>>>> master + '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)) + '@vueuse/shared': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)) optionalDependencies: focus-trap: 7.5.4 transitivePeerDependencies: @@ -9506,15 +9362,9 @@ snapshots: '@vueuse/metadata@11.0.3': {} -<<<<<<< HEAD - '@vueuse/shared@11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4))': - dependencies: - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) -======= - '@vueuse/shared@11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3))': + '@vueuse/shared@11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4))': dependencies: - vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)) ->>>>>>> master + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -14971,42 +14821,26 @@ snapshots: fsevents: 2.3.3 terser: 5.27.0 -<<<<<<< HEAD - vitepress@1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.5.4): -======= - vitepress@1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(postcss@8.4.41)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.3.3): ->>>>>>> master + vitepress@1.3.4(@algolia/client-search@4.23.2)(@types/node@22.5.3)(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(postcss@8.4.45)(search-insights@2.13.0)(terser@5.27.0)(typescript@5.5.4): dependencies: '@docsearch/css': 3.6.1 '@docsearch/js': 3.6.1(@algolia/client-search@4.23.2)(search-insights@2.13.0) '@shikijs/core': 1.14.1 '@shikijs/transformers': 1.14.1 '@types/markdown-it': 14.1.2 -<<<<<<< HEAD - '@vitejs/plugin-vue': 5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.4.38(typescript@5.5.4)) + '@vitejs/plugin-vue': 5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.5.4)) '@vue/devtools-api': 7.3.9 '@vue/shared': 3.4.38 - '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)) - '@vueuse/integrations': 11.0.3(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(focus-trap@7.5.4)(vue@3.4.38(typescript@5.5.4)) -======= - '@vitejs/plugin-vue': 5.1.2(vite@5.2.8(@types/node@22.5.3)(terser@5.27.0))(vue@3.5.1(typescript@5.3.3)) - '@vue/devtools-api': 7.3.9 - '@vue/shared': 3.4.38 - '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)) - '@vueuse/integrations': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(focus-trap@7.5.4)(vue@3.5.1(typescript@5.3.3)) ->>>>>>> master + '@vueuse/core': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)) + '@vueuse/integrations': 11.0.3(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(focus-trap@7.5.4)(vue@3.5.1(typescript@5.5.4)) focus-trap: 7.5.4 mark.js: 8.11.1 minisearch: 7.1.0 shiki: 1.14.1 vite: 5.2.8(@types/node@22.5.3)(terser@5.27.0) -<<<<<<< HEAD - vue: 3.4.38(typescript@5.5.4) -======= - vue: 3.5.1(typescript@5.3.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) optionalDependencies: - postcss: 8.4.41 + postcss: 8.4.45 transitivePeerDependencies: - '@algolia/client-search' - '@types/node' @@ -15071,19 +14905,11 @@ snapshots: vm-browserify@1.1.2: {} -<<<<<<< HEAD - vue-demi@0.14.10(@vue/composition-api@1.7.2(vue@3.4.38(typescript@5.5.4)))(vue@3.4.38(typescript@5.5.4)): - dependencies: - vue: 3.4.38(typescript@5.5.4) - optionalDependencies: - '@vue/composition-api': 1.7.2(vue@3.4.38(typescript@5.5.4)) -======= - vue-demi@0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.3.3)))(vue@3.5.1(typescript@5.3.3)): + vue-demi@0.14.10(@vue/composition-api@1.7.2(vue@3.5.1(typescript@5.5.4)))(vue@3.5.1(typescript@5.5.4)): dependencies: - vue: 3.5.1(typescript@5.3.3) + vue: 3.5.1(typescript@5.5.4) optionalDependencies: - '@vue/composition-api': 1.7.2(vue@3.5.1(typescript@5.3.3)) ->>>>>>> master + '@vue/composition-api': 1.7.2(vue@3.5.1(typescript@5.5.4)) vue-eslint-parser@9.4.3(eslint@9.9.1(jiti@1.21.0)): dependencies: @@ -15098,11 +14924,7 @@ snapshots: transitivePeerDependencies: - supports-color -<<<<<<< HEAD - vue-loader@16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.4.38(typescript@5.5.4))(webpack@4.47.0(webpack-cli@3.3.12)): -======= - vue-loader@16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.5.1(typescript@5.4.3))(webpack@4.47.0(webpack-cli@3.3.12)): ->>>>>>> master + vue-loader@16.8.3(@vue/compiler-sfc@3.4.19)(vue@3.5.1(typescript@5.5.4))(webpack@4.47.0(webpack-cli@3.3.12)): dependencies: chalk: 4.1.2 hash-sum: 2.0.0 @@ -15110,28 +14932,17 @@ snapshots: webpack: 4.47.0(webpack-cli@3.3.12) optionalDependencies: '@vue/compiler-sfc': 3.4.19 -<<<<<<< HEAD - vue: 3.4.38(typescript@5.5.4) -======= - vue: 3.5.1(typescript@5.4.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) vue-router@4.2.5(vue@3.5.1(typescript@5.3.3)): dependencies: '@vue/devtools-api': 6.5.1 vue: 3.5.1(typescript@5.3.3) -<<<<<<< HEAD - vue-router@4.2.5(vue@3.4.38(typescript@5.5.4)): + vue-router@4.2.5(vue@3.5.1(typescript@5.5.4)): dependencies: '@vue/devtools-api': 6.5.1 - vue: 3.4.38(typescript@5.5.4) -======= - vue-router@4.2.5(vue@3.5.1(typescript@5.4.3)): - dependencies: - '@vue/devtools-api': 6.5.1 - vue: 3.5.1(typescript@5.4.3) ->>>>>>> master + vue: 3.5.1(typescript@5.5.4) vue-template-compiler@2.7.16: dependencies: @@ -15169,23 +14980,13 @@ snapshots: optionalDependencies: typescript: 5.3.3 -<<<<<<< HEAD - vue@3.4.38(typescript@5.5.4): - dependencies: - '@vue/compiler-dom': 3.4.38 - '@vue/compiler-sfc': 3.4.38 - '@vue/runtime-dom': 3.4.38 - '@vue/server-renderer': 3.4.38(vue@3.4.38(typescript@5.5.4)) - '@vue/shared': 3.4.38 -======= - vue@3.5.1(typescript@5.4.3): + vue@3.5.1(typescript@5.5.4): dependencies: '@vue/compiler-dom': 3.5.1 '@vue/compiler-sfc': 3.5.1 '@vue/runtime-dom': 3.5.1 - '@vue/server-renderer': 3.5.1(vue@3.5.1(typescript@5.4.3)) + '@vue/server-renderer': 3.5.1(vue@3.5.1(typescript@5.5.4)) '@vue/shared': 3.5.1 ->>>>>>> master optionalDependencies: typescript: 5.5.4 From 48db1588554e2689cca9207207088a85b2ac6601 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Thu, 5 Sep 2024 17:32:40 +0900 Subject: [PATCH 3/3] refactor: remove comments --- packages/core-base/src/types/utils.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/core-base/src/types/utils.ts b/packages/core-base/src/types/utils.ts index 1143cca9d..69510e519 100644 --- a/packages/core-base/src/types/utils.ts +++ b/packages/core-base/src/types/utils.ts @@ -189,13 +189,5 @@ export type StringConvertable> = IsNever extends (...args: any) => string -// ? T -// : unknown -// export type StringConvertable = IsNever> extends true -// ? unknown -// : ExtractToStringFunction extends (...args: any) => string -// ? T -// : unknown /* eslint-enable @typescript-eslint/no-explicit-any */