@vocab/types
Advanced tools
Comparing version 1.1.2 to 1.2.0
export { FormatXMLElementFn } from 'intl-messageformat'; | ||
export declare type LanguageName = string; | ||
export declare type TranslationKey = string; | ||
export declare type TranslationMessage = string; | ||
export declare type ParsedFormatFn = (parts: any) => any; | ||
export declare type ParsedFormatFnByKey = Record<string, ParsedFormatFn>; | ||
export declare type ICUFormatResult<T = unknown> = string | T | (string | T); | ||
export type LanguageName = string; | ||
export type TranslationKey = string; | ||
export type TranslationMessage = string; | ||
export type ParsedFormatFn = (parts: any) => any; | ||
export type ParsedFormatFnByKey = Record<string, ParsedFormatFn>; | ||
export type ICUFormatResult<T = unknown> = string | T | (string | T); | ||
/** | ||
* Equivalent to the `string` type, but tricks the language server into prodiving | ||
* suggestions for string literals passed into the `Suggestions` generic parameter | ||
* | ||
* @example | ||
* Accept any string, but suggest specific animals | ||
* ``` | ||
* type AnyAnimal = StringWithSuggestions<"cat" | "dog">; | ||
* // Suggests cat and dog, but accepts any string | ||
* const animal: AnyAnimal = ""; | ||
* ``` | ||
*/ | ||
export type StringWithSuggestions<Suggestions extends string> = Suggestions | Omit<string, Suggestions>; | ||
/** | ||
* ParsedICUMessage A strictly typed formatter from intl-messageformat | ||
@@ -14,3 +27,3 @@ */ | ||
} | ||
export declare type ParsedICUMessages<FormatFnByKey extends ParsedFormatFnByKey> = { | ||
export type ParsedICUMessages<FormatFnByKey extends ParsedFormatFnByKey> = { | ||
[key in keyof FormatFnByKey]: ParsedICUMessage<FormatFnByKey[key]>; | ||
@@ -21,11 +34,11 @@ }; | ||
*/ | ||
export declare type TranslationModule<FormatFnByKey extends ParsedFormatFnByKey> = { | ||
export type TranslationModule<FormatFnByKey extends ParsedFormatFnByKey> = { | ||
getValue: (locale: string) => ParsedICUMessages<FormatFnByKey> | undefined; | ||
load: () => Promise<void>; | ||
}; | ||
export declare type TranslationModuleByLanguage<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = Record<Language, TranslationModule<FormatFnByKey>>; | ||
export type TranslationModuleByLanguage<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = Record<Language, TranslationModule<FormatFnByKey>>; | ||
/** | ||
* TranslationFile contains a record of TranslationModules per language, exposing a set of methods to load and return the module by language | ||
*/ | ||
export declare type TranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = { | ||
export type TranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = { | ||
/** | ||
@@ -83,3 +96,3 @@ * Retrieve messages. If not loaded, will attempt to load messages and resolve once complete. | ||
} | ||
export declare type Tags = Array<string>; | ||
export type Tags = Array<string>; | ||
export interface TranslationFileMetadata { | ||
@@ -93,9 +106,9 @@ tags?: Tags; | ||
} | ||
export declare type TranslationsByKey<Key extends TranslationKey = string> = Record<Key, TranslationData>; | ||
export declare type TranslationFileContents = TranslationsByKey & { | ||
export type TranslationsByKey<Key extends TranslationKey = string> = Record<Key, TranslationData>; | ||
export type TranslationFileContents = TranslationsByKey & { | ||
_meta?: TranslationFileMetadata; | ||
}; | ||
export declare type TranslationMessagesByKey<Key extends TranslationKey = string> = Record<Key, TranslationMessage>; | ||
export declare type TranslationsByLanguage<Key extends TranslationKey = string> = Record<LanguageName, TranslationsByKey<Key>>; | ||
export declare type LoadedTranslation<Key extends TranslationKey = string> = { | ||
export type TranslationMessagesByKey<Key extends TranslationKey = string> = Record<Key, TranslationMessage>; | ||
export type TranslationsByLanguage<Key extends TranslationKey = string> = Record<LanguageName, TranslationsByKey<Key>>; | ||
export type LoadedTranslation<Key extends TranslationKey = string> = { | ||
namespace: string; | ||
@@ -102,0 +115,0 @@ keys: Array<Key>; |
@@ -11,5 +11,3 @@ 'use strict'; | ||
enumerable: true, | ||
get: function () { | ||
return intlMessageformat.FormatXMLElementFn; | ||
} | ||
get: function () { return intlMessageformat.FormatXMLElementFn; } | ||
}); |
@@ -11,5 +11,3 @@ 'use strict'; | ||
enumerable: true, | ||
get: function () { | ||
return intlMessageformat.FormatXMLElementFn; | ||
} | ||
get: function () { return intlMessageformat.FormatXMLElementFn; } | ||
}); |
{ | ||
"name": "@vocab/types", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"main": "dist/vocab-types.cjs.js", | ||
@@ -14,2 +14,2 @@ "module": "dist/vocab-types.esm.js", | ||
} | ||
} | ||
} |
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
23025
9
138