Skip to content

All i18n type definitions are of type 'any' #26022

Closed

Description

Describe the bug
Type definitions in default-i18n.d.ts for the @wordpress/i18n package generated by npm run build:package-types are all of type any. For example, the __ function definition looks like this:

/**
 * 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 __: any;

To reproduce
Steps to reproduce the behavior:

  1. npm run build:package-types
  2. Or, from a plugin/theme context, after installing @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:

/**
 * 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 function __(text: string, domain?: string | undefined): string;

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):

i18n-intellisense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Needs DevReady for, and needs developer efforts[Package] i18n/packages/i18n[Type] BugAn existing feature does not function as intendednpm PackagesRelated to npm packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions