-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
All i18n type definitions are of type 'any' #26022
Comments
@sirreal, any idea why it might generate incorrect type definition? |
👋 Thanks for the report and the ping! I hadn't seen this report, but I took a look and suspect that I (inadvertently) fixed this in #26171. Not that this doesn't appear to be released on npm yet. I've just compiled latest master and the results are accurate types: /**
* @typedef {import('./create-i18n').LocaleData} LocaleData
*/
/**
* Merges locale data into the Tannin instance by domain. Accepts data in a
* Jed-formatted JSON object shape.
*
* @see http://messageformat.github.io/Jed/
*
* @param {LocaleData} [data] Locale data configuration.
* @param {string} [domain] Domain for which configuration applies.
*/
export const setLocaleData: (data?: Record<string, any> | undefined, domain?: string | undefined) => void;
/**
* Retrieve the translation of text.
*
* @see https://developer.wordpress.org/reference/functions/__/
*
* @param {string} text Text to translate.
* @param {string} [domain] Domain to retrieve the translated text.
*
* @return {string} Translated text.
*/
export const __: (text: string, domain?: string | undefined) => string;
/**
* Retrieve translated string with gettext context.
*
* @see https://developer.wordpress.org/reference/functions/_x/
*
* @param {string} text Text to translate.
* @param {string} context Context information for the translators.
* @param {string} [domain] Domain to retrieve the translated text.
*
* @return {string} Translated context string without pipe.
*/
export const _x: (text: string, context: string, domain?: string | undefined) => string;
/**
* Translates and retrieves the singular or plural form based on the supplied
* number.
*
* @see https://developer.wordpress.org/reference/functions/_n/
*
* @param {string} single The text to be used if the number is singular.
* @param {string} plural The text to be used if the number is plural.
* @param {number} number The number to compare against to use either the
* singular or plural form.
* @param {string} [domain] Domain to retrieve the translated text.
*
* @return {string} The translated singular or plural form.
*/
export const _n: (single: string, plural: string, number: number, domain?: string | undefined) => string;
/**
* Translates and retrieves the singular or plural form based on the supplied
* number, with gettext context.
*
* @see https://developer.wordpress.org/reference/functions/_nx/
*
* @param {string} single The text to be used if the number is singular.
* @param {string} plural The text to be used if the number is plural.
* @param {number} number The number to compare against to use either the
* singular or plural form.
* @param {string} context Context information for the translators.
* @param {string} [domain] Domain to retrieve the translated text.
*
* @return {string} The translated singular or plural form.
*/
export const _nx: (single: string, plural: string, number: number, context: string, domain?: string | undefined) => string;
/**
* Check if current locale is RTL.
*
* **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
* For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
* language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
* including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
*
* @return {boolean} Whether locale is RTL.
*/
export const isRTL: () => boolean;
export type LocaleData = {
[x: string]: any;
};
//# sourceMappingURL=default-i18n.d.ts.map I'll close because this should be improved as soon as the package is released. |
Sorry about the bump but this fix has yet to be released. Do you know when it will be published? |
No problem. I believe this comment applies: #26866 (comment). The package releases are on hold until the WordPress release is complete. They should begin again in the next few days. |
Describe the bug
Type definitions in
default-i18n.d.ts
for the@wordpress/i18n
package generated bynpm run build:package-types
are all of typeany
. For example, the__
function definition looks like this:To reproduce
Steps to reproduce the behavior:
npm run build:package-types
@wordpress/i18n
, import the function:import { __ } from '@wordpress/i18n'
Expected behavior
I expect the type definitions to be similar, if not the same, as described in #18942, like so:
Screenshots
I'm developing a plugin with TypeScript React that uses the
@wordpress/i18n
package and excludes it from my webpack build. The following screenshot is what intellisense shows me in vscode (sorry about the small screenshot):The text was updated successfully, but these errors were encountered: