international-types
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -26,3 +26,3 @@ export type LocaleValue = string | number | boolean | null | undefined | Date; | ||
}[keyof T] : ''; | ||
type FollowPath<T, P> = P extends `${infer U}.${infer R}` ? U extends keyof T ? FollowPath<T[U], R> : never : P extends keyof T ? T[P] : never; | ||
type FollowPath<T, P> = P extends `${infer U}.${infer R}` ? U extends keyof T ? FollowPath<T[U], R> : P extends keyof T ? T[P] : never : P extends keyof T ? T[P] : never; | ||
export type FlattenLocale<Locale extends Record<string, unknown>> = { | ||
@@ -29,0 +29,0 @@ [K in Leaves<Locale>]: FollowPath<Locale, K>; |
{ | ||
"name": "international-types", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Type-safe internationalization (i18n) utility types", | ||
@@ -23,3 +23,4 @@ "types": "dist/index.d.ts", | ||
}, | ||
"homepage": "https://github.com/QuiiBz/next-international#readme", | ||
"homepage": "https://next-international.vercel.app", | ||
"license": "MIT", | ||
"scripts": { | ||
@@ -26,0 +27,0 @@ "build": "tsc --declaration --emitDeclarationOnly --outDir dist index.ts" |
@@ -61,3 +61,3 @@ <p align="center"> | ||
function scopedT<Scope extends Scopes<Locale>>(scope: Scope) { | ||
function t<Key extends LocaleKeys<Locale, Scope>>(key: Key) { | ||
return function t<Key extends LocaleKeys<Locale, Scope>>(key: Key) { | ||
// ... | ||
@@ -78,3 +78,3 @@ } | ||
```ts | ||
import type { LocaleKeys, LocaleValue } from 'international-types' | ||
import type { LocaleKeys, BaseLocale, Scopes, ScopedValue, CreateParams, ParamsObject } from 'international-types' | ||
@@ -86,9 +86,13 @@ type Locale = { | ||
function t< | ||
Key extends LocaleKeys<Locale, undefined>, | ||
Value extends LocaleValue = ScopedValue<Locale, undefined, Key>, | ||
>(key: Key, param: ParamsObject<Value>) { | ||
// ... | ||
function scopedT<Locale extends BaseLocale, Scope extends Scopes<Locale> | undefined>(scope?: Scope) { | ||
return function t<Key extends LocaleKeys<Locale, Scope>, Value extends ScopedValue<Locale, Scope, Key>>( | ||
key: Key, | ||
...params: CreateParams<ParamsObject<Value>, Locale, Scope, Key, Value> | ||
) { | ||
// ... | ||
} | ||
} | ||
const t = scopedT<Locale, undefined>(); | ||
t('param', { | ||
@@ -95,0 +99,0 @@ value: '' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
9761
0
110