Skip to content

Fix type definitions for i18n component and v-t directive #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 48 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
// #region Vue 2
declare module 'vue/types/vue' {
interface Vue {
$t: (key: string, values?: Record<string, unknown>) => string
$ta: (key: string, values?: Record<string, unknown>) => Record<string, string>
import { PropType, DefineComponent, FunctionDirective } from 'vue-demi'
import { FluentVariable } from '@fluent/bundle'

type ComponentType = DefineComponent<{
/**
* The key of the translation.
*/
path: {
type: StringConstructor,
required: true,
},
/**
* Arguments to pass to the translation.
*/
args: {
type: PropType<Record<string, FluentVariable>>,
default: () => Record<string, FluentVariable>,
},
/**
* The tag to use as a root element.
*/
tag: {
type: StringConstructor,
default: 'span',
},
/**
* Whether to render translation as html.
*/
html: {
type: BooleanConstructor,
default: false,
},
/**
* Whether to render translation without a root element.
*/
noTag: {
type: BooleanConstructor,
default: false,
}
}
// #endregion
}>

// #region Vue 3
declare module '@vue/runtime-core' {
declare module 'vue' {
interface ComponentCustomProperties {
$t: (key: string, values?: Record<string, unknown>) => string
$ta: (key: string, values?: Record<string, unknown>) => Record<string, string>
}

interface ComponentCustomProperties {
vT: FunctionDirective<HTMLElement, Record<string, FluentVariable>>
}

interface GlobalComponents {
i18n: ComponentType
}
}
// #endregion

export * from './dist'
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy