UNPKG

@snap/camera-kit

Version:
55 lines 2.68 kB
/** * This implementation is limited by how TypeScript currently implements tag function for template literals. * * The way tag functions are typed by the TypeScript compiler limits their usefulness, for two reasons: * * 1. Specific literal types are not inferred from interpolation expressions -- the following does not work: * ```ts * function tag<K extends readonly string[]>(strings: readonly string[], ...keys: K): string { ... } * tag`This is a ${"test"} template.` // the K type parameter is not correctly inferred as `readonly ['test']` * ``` * 2. The return type of a function used as a tag function will always be `string` -- the following does not work: * ```ts * function tag<K extends readonly string[]>( * strings: readonly string[], * ...keys: K * ): (values: {[k in K[number]]: string}) => string { ... } * * const template = tag`This is a ${"test"} template` // TS infers the type of `template` as `string` -- clearly wrong. * ``` * * An attempt is made here to work around those limitations and still provide a reasonably amount of type safety without * adding too much verbosity. * * See https://github.com/microsoft/TypeScript/pull/49552 */ type TemplateFunction<K extends readonly string[], V extends { [key in K[number]]: string; }> = (values: V) => string; interface LocalizableStrings { legalPromptMessage: TemplateFunction<readonly ["privacyPolicyUrl", "termsOfServiceUrl", "learnMoreUrl"], { privacyPolicyUrl: string; termsOfServiceUrl: string; learnMoreUrl: string; }>; legalPromptAccept: string; legalPromptReject: string; legalPromptTermsOfService: string; legalPromptVariantGMessage: string; legalPromptVariantGAdultOrChild: string; legalPromptVariantGFindYourParent: string; legalPromptVariantGIAmGuardian: string; legalPromptVariantGCancel: string; legalPromptVariantGAdult: string; legalPromptVariantGChild: string; } /** * The most closest locale with a translation. */ export declare const supportedLocale: "en-US" | "ar" | "bn-BD" | "bn-IN" | "da-DK" | "de-DE" | "el-GR" | "en-GB" | "es" | "es-AR" | "es-ES" | "es-MX" | "fi-FI" | "fil-PH" | "fr-FR" | "gu-IN" | "hi-IN" | "id-ID" | "it-IT" | "ja-JP" | "kn-IN" | "ko-KR" | "ml-IN" | "mr-IN" | "ms-MY" | "nb-NO" | "nl-NL" | "pa" | "pl-PL" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "sv-SE" | "ta-IN" | "te-IN" | "th-TH" | "tr-TR" | "ur-PK" | "vi-VN" | "zh-Hans" | "zh-Hant"; /** * Returns localized string by its ID. */ export declare function localizedString<ID extends keyof LocalizableStrings>(stringId: ID): LocalizableStrings[ID]; export {}; //# sourceMappingURL=localization.d.ts.map