-
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: configurable custom property
$i18n
type (#2094)
- Loading branch information
1 parent
a9a8029
commit de2523d
Showing
4 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,44 @@ | ||
import type { IsNever } from '@intlify/core-base' | ||
import type { ExportedGlobalComposer } from './i18n' | ||
import type { VueI18n } from './legacy' | ||
|
||
export type Disposer = () => void | ||
|
||
/** | ||
* | ||
* The interface used for narrowing types using generated types. | ||
* | ||
* @remarks | ||
* | ||
* The type generated by 3rd party (e.g. nuxt/i18n) | ||
* | ||
* @example | ||
* ```ts | ||
* // generated-i18n-types.d.ts (`.d.ts` file at your app) | ||
* | ||
* declare module '@intlify/vue-i18n-core' { | ||
* interface GeneratedTypeConfig { | ||
* legacy: false | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
export interface GeneratedTypeConfig {} | ||
|
||
/** | ||
* Narrowed i18n instance type based on `GeneratedTypeConfig['legacy']` | ||
* | ||
* - `never` (unset) resolves to `VueI18n | ExportedGlobalComposer` | ||
* - `true` resolves to `VueI18n` | ||
* - `false` resolves to `ExportedGlobalComposer` | ||
*/ | ||
export type GeneratedInstanceType = | ||
GeneratedTypeConfig extends Record<'legacy', infer Legacy> ? Legacy : never | ||
|
||
/** @VueI18nGeneral */ | ||
export type VueI18nInstance = | ||
IsNever<GeneratedInstanceType> extends true | ||
? VueI18n | ExportedGlobalComposer | ||
: GeneratedInstanceType extends true | ||
? VueI18n | ||
: ExportedGlobalComposer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters