Skip to content

Commit

Permalink
fix: Intl type definition for TS 4.2 (#422)
Browse files Browse the repository at this point in the history
closes #430
  • Loading branch information
kazupon committed Apr 5, 2021
1 parent 3763c97 commit 06617bd
Show file tree
Hide file tree
Showing 10 changed files with 1,486 additions and 1,434 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,43 @@
"test:unit": "yarn clean:cache:jest && cross-env NODE_ICU_DATA=./node_modules/full-icu jest --env node"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.9.22",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.3.3",
"@microsoft/api-extractor": "^7.13.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-replace": "^2.4.0",
"@textlint-rule/textlint-rule-no-unmatched-pair": "^1.0.7",
"@types/jest": "^26.0.14",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
"@vue/devtools-api": "^6.0.0-beta.5",
"@vue/devtools-api": "^6.0.0-beta.7",
"@vue/server-renderer": "^3.0.0",
"algoliasearch": "^4.8.2",
"api-docs-gen": "^0.2.6",
"brotli": "^1.3.2",
"chalk": "^4.1.0",
"convert-hrtime": "^3.0.0",
"cross-env": "^7.0.2",
"eslint": "^7.16.0",
"eslint-config-prettier": "^8.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-vue": "^7.4.0",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.0",
"eslint-plugin-vue": "^7.8.0",
"eslint-plugin-vue-libs": "^4.0.0",
"execa": "^5.0.0",
"fixpack": "^4.0.0",
"fs-extra": "^9.0.0",
"full-icu": "^1.3.1",
"http-server": "^0.12.1",
"husky": "^4.3.0",
"jest": "^26.4.2",
"jest": "^26.6.3",
"jest-puppeteer": "^4.4.0",
"jest-watch-typeahead": "^0.6.1",
"jest-watch-typeahead": "^0.6.2",
"lerna-changelog": "^1.0.1",
"lint-staged": "^10.5.1",
"minimist": "^1.2.5",
"npm-run-all": "^4.1.5",
"opener": "^1.5.1",
"prettier": "^2.1.2",
"opener": "^1.5.2",
"prettier": "^2.2.1",
"puppeteer": "^2.1.1",
"rollup": "^2.35.0",
"rollup-plugin-node-builtins": "^2.1.2",
Expand All @@ -116,9 +116,9 @@
"textlint-rule-terminology": "^2.1.4",
"textlint-rule-unexpanded-acronym": "^1.2.4",
"textlint-rule-write-good": "^1.6.2",
"ts-jest": "^26.4.0",
"typescript": "^4.1.2",
"typescript-eslint-language-service": "^4.1.2",
"ts-jest": "^26.5.4",
"typescript": "^4.2.3",
"typescript-eslint-language-service": "^4.1.3",
"vitepress": "^0.12.2",
"vue": "^3.0.0"
},
Expand Down
14 changes: 8 additions & 6 deletions packages/core-base/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

export type DateTimeHumanReadable = 'long' | 'short' | 'narrow'
export type DateTimeDigital = 'numeric' | '2-digit'
export type LocaleMatcher = 'lookup' | 'best fit'
export type FormatMatcher = 'basic' | 'best fit'

export interface SpecificDateTimeFormatOptions
extends Intl.DateTimeFormatOptions {
Expand All @@ -16,8 +18,8 @@ export interface SpecificDateTimeFormatOptions
weekday?: DateTimeHumanReadable
era?: DateTimeHumanReadable
timeZoneName?: 'long' | 'short'
localeMatcher?: 'lookup' | 'best-fit'
formatMatcher?: 'basic' | 'best-fit'
localeMatcher?: LocaleMatcher
formatMatcher?: FormatMatcher
}
export type DateTimeFormatOptions =
| Intl.DateTimeFormatOptions
Expand All @@ -35,16 +37,16 @@ export interface SpecificNumberFormatOptions extends Intl.NumberFormatOptions {
style?: 'decimal' | 'percent'
currency?: string
currencyDisplay?: CurrencyDisplay
localeMatcher?: 'lookup' | 'best-fit'
formatMatcher?: 'basic' | 'best-fit'
localeMatcher?: LocaleMatcher
formatMatcher?: FormatMatcher
}

export interface CurrencyNumberFormatOptions extends Intl.NumberFormatOptions {
style: 'currency'
currency: string // Obligatory if style is 'currency'
currencyDisplay?: CurrencyDisplay
localeMatcher?: 'lookup' | 'best fit'
formatMatcher?: 'basic' | 'best fit'
localeMatcher?: LocaleMatcher
formatMatcher?: FormatMatcher
}

export type NumberFormatOptions =
Expand Down
4 changes: 3 additions & 1 deletion packages/core-base/test/datetime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import { CoreErrorCodes, errorMessages } from '../src/errors'
import { registerMessageCompiler } from '../src/context'
import { compileToFunction } from '../src/compile'

const datetimeFormats = {
import type { DateTimeFormats } from '../src/types'

const datetimeFormats: DateTimeFormats = {
'en-US': {
short: {
// DD/MM/YYYY, hh:mm (AM|PM)
Expand Down
2 changes: 2 additions & 0 deletions packages/vue-i18n/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export {
DateTimeFormat as IntlDateTimeFormat,
DateTimeFormats as IntlDateTimeFormats,
NumberFormats as IntlNumberFormats,
LocaleMatcher as IntlLocaleMatcher,
FormatMatcher as IntlFormatMatcher,
MessageFunction,
MessageFunctions,
PluralizationRule,
Expand Down
2 changes: 2 additions & 0 deletions packages/vue-i18n/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export {
DateTimeFormat as IntlDateTimeFormat,
DateTimeFormats as IntlDateTimeFormats,
NumberFormats as IntlNumberFormats,
LocaleMatcher as IntlLocaleMatcher,
FormatMatcher as IntlFormatMatcher,
MessageFunction,
MessageFunctions,
PluralizationRule,
Expand Down
1 change: 1 addition & 0 deletions packages/vue-i18n/test/__snapshots__/composer.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Array [
"ref": null,
"scopeId": null,
"shapeFlag": 8,
"slotScopeIds": null,
"ssContent": null,
"ssFallback": null,
"staticCount": 0,
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-i18n/test/components/DatetimeFormat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import { mount } from '../helper'
import { defineComponent, SetupContext, VNodeChild, h } from 'vue'
import { createI18n } from '../../src/index'
import { createI18n, IntlDateTimeFormats } from '../../src/index'

const datetimeFormats = {
const datetimeFormats: IntlDateTimeFormats = {
'en-US': {
long: {
year: 'numeric',
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-i18n/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export function mount<
}

activeWrapperRemovers.push(() => {
app.unmount(rootEl)
app.unmount()
rootEl.remove()
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-i18n/test/mixin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ test.skip('beforeDestroy', async () => {
})

const App = defineComponent({ template: '<br/>' })
const { app, rootEl, vm } = await mount(App, i18n)
const { app, vm } = await mount(App, i18n)

app.unmount(rootEl)
app.unmount()
await nextTick()

expect(vm.$i18n).toBeUndefined()
Expand Down

0 comments on commit 06617bd

Please sign in to comment.