Skip to content

Commit

Permalink
use optional notion from jsdoc, add temporary module definition for @…
Browse files Browse the repository at this point in the history
…wordpress/api-fetch
  • Loading branch information
gwwar committed Mar 23, 2021
1 parent 56d20e4 commit 9cfa345
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* WordPress dependencies
*/
// @ts-ignore TODO
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import { decodeEntities } from '@wordpress/html-entities';
Expand All @@ -16,20 +15,20 @@ import { __ } from '@wordpress/i18n';
/**
* @typedef WPLinkSearchOptions
*
* @property {?boolean} isInitialSuggestions Displays initial search suggestions, when true.
* @property {?WPLinkSearchType} type Filters by search type.
* @property {?string} subtype Slug of the post-type or taxonomy.
* @property {?number} page Which page of results to return.
* @property {?number} perPageArg Search results per page.
* @property {boolean} [isInitialSuggestions] Displays initial search suggestions, when true.
* @property {WPLinkSearchType} [type] Filters by search type.
* @property {string} [subtype] Slug of the post-type or taxonomy.
* @property {number} [page] Which page of results to return.
* @property {number} [perPageArg] Search results per page.
*/

/**
* @typedef WPLinkSearchResult
*
* @property {?number} id Post or term id.
* @property {?string} url Link url.
* @property {?string} title Title of the link.
* @property {?string} type The taxonomy or post type slug or type URL.
* @property {number} id Post or term id.
* @property {string} url Link url.
* @property {string} title Title of the link.
* @property {string} type The taxonomy or post type slug or type URL.
*/

/**
Expand All @@ -43,7 +42,7 @@ import { __ } from '@wordpress/i18n';
* Returns a function that when invoked, fetches link suggestions from the API.
*
* @param {Object} [editorSettings]
* @param {?boolean} [editorSettings.disablePostFormats]
* @param {boolean} [editorSettings.disablePostFormats]
*
* @example
* ```js
Expand Down
5 changes: 5 additions & 0 deletions packages/wordpress-block-editor-config/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//TODO: delete this when api-fetch provides type definitions
// see https://github.com/WordPress/gutenberg/pull/29993#discussion_r599066110
declare module '@wordpress/api-fetch' {
export default function ( request: { path: string } ): Promise< any >;
}

0 comments on commit 9cfa345

Please sign in to comment.