Skip to content

Commit 8f147ab

Browse files
committed
docs: update JSDoc Array syntax for better TypeScript usability
1 parent 6e1879f commit 8f147ab

10 files changed

Lines changed: 24 additions & 24 deletions

File tree

packages/kitsu-core/src/deattribute/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Hoists attributes to be top-level
33
*
4-
* @param {Object|Array} data Resource data
5-
* @returns {Object|Array} Deattributed resource data
4+
* @param {Object|Object[]} data Resource data
5+
* @returns {Object|Object[]} Deattributed resource data
66
*
77
* @example <caption>Deattribute an array of resources</caption>
88
* // JSON:API 'data' field

packages/kitsu-core/src/filterIncludes/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { error } from '../error'
77
* @param {Object} relationship
88
* @param {string} relationship.id The relationship ID
99
* @param {string} relationship.type The relationship type
10-
* @returns {Array<Object>} The matched includes
10+
* @returns {Object[]} The matched includes
1111
*
1212
* @example
1313
* const includes = [

packages/kitsu-core/src/serialise/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function hasID (node) {
106106
* Handles the Bulk Extension support. See `serialise` for examples.
107107
*
108108
* @param {string} type Resource type
109-
* @param {Array<Object>} payload The data
109+
* @param {Object[]} payload The data
110110
* @param {string} method Request type (PATCH, POST, DELETE)
111111
* @param {Object} options Optional configuration for camelCase and pluralisation handling
112112
* @param {Function} options.camelCaseTypes Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core
@@ -164,7 +164,7 @@ function serialiseRootObject (type, payload, method, options) {
164164
* Serialises an object into a JSON-API structure
165165
*
166166
* @param {string} type Resource type
167-
* @param {Object|Array<Object>} data The data
167+
* @param {Object|Object[]} data The data
168168
* @param {string} method Request type (PATCH, POST, DELETE)
169169
* @param {Object} options Optional configuration for camelCase and pluralisation handling
170170
* @param {Function} options.camelCaseTypes Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core

packages/kitsu-core/src/splitModel/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @param {Object} options
88
* @param {Function} options.resourceCase Convert libraryEntries to library-entries or library_entries (default no conversion). To use parameter, import kebab or snake from kitsu-core
99
* @param {Function} options.pluralModel Pluralise models (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package)
10-
* @returns {Array<string, string>} Array containing the model name and the resource URL with pluralisation applied
10+
* @returns {[string, string]}} Array containing the model name and the resource URL with pluralisation applied
1111
*
1212
* @example
1313
* splitModel('posts/1/comments')

packages/kitsu-core/types/deattribute/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Hoists attributes to be top-level
33
*
4-
* @param {Object|Array} data Resource data
5-
* @returns {Object|Array} Deattributed resource data
4+
* @param {Object|Object[]} data Resource data
5+
* @returns {Object|Object[]} Deattributed resource data
66
*
77
* @example <caption>Deattribute an array of resources</caption>
88
* // JSON:API 'data' field
@@ -26,4 +26,4 @@
2626
*
2727
* const output = deattribute(data) // { id: '1', type: 'users', slug: 'wopian' }
2828
*/
29-
export function deattribute(data: any | Array): any | Array;
29+
export function deattribute(data: any | any[]): any | any[];

packages/kitsu-core/types/filterIncludes/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param {Object} relationship
66
* @param {string} relationship.id The relationship ID
77
* @param {string} relationship.type The relationship type
8-
* @returns {Array<Object>} The matched includes
8+
* @returns {Object[]} The matched includes
99
*
1010
* @example
1111
* const includes = [
@@ -31,4 +31,4 @@
3131
export function filterIncludes(included: any, { id, type }: {
3232
id: string;
3333
type: string;
34-
}): Array<any>;
34+
}): any[];

packages/kitsu-core/types/serialise/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Serialises an object into a JSON-API structure
33
*
44
* @param {string} type Resource type
5-
* @param {Object|Array<Object>} data The data
5+
* @param {Object|Object[]} data The data
66
* @param {string} method Request type (PATCH, POST, DELETE)
77
* @param {Object} options Optional configuration for camelCase and pluralisation handling
88
* @param {Function} options.camelCaseTypes Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core
@@ -28,7 +28,7 @@
2828
* // { data: { id: '1', type: 'anime', attributes: { slug: 'shirobako' } } }
2929
* const output = serialise(model, obj, 'PATCH')
3030
*/
31-
export function serialise(type: string, data?: any | Array<any>, method?: string, options?: {
31+
export function serialise(type: string, data?: any | any[], method?: string, options?: {
3232
camelCaseTypes: Function;
3333
pluralTypes: Function;
3434
}): any;

packages/kitsu-core/types/splitModel/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param {Object} options
77
* @param {Function} options.resourceCase Convert libraryEntries to library-entries or library_entries (default no conversion). To use parameter, import kebab or snake from kitsu-core
88
* @param {Function} options.pluralModel Pluralise models (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package)
9-
* @returns {Array<string, string>} Array containing the model name and the resource URL with pluralisation applied
9+
* @returns {[string, string]}} Array containing the model name and the resource URL with pluralisation applied
1010
*
1111
* @example
1212
* splitModel('posts/1/comments')
@@ -28,4 +28,4 @@
2828
export function splitModel(url: string, options?: {
2929
resourceCase: Function;
3030
pluralModel: Function;
31-
}): Array<string, string>;
31+
}): [string, string];

packages/kitsu/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export default class Kitsu {
295295
*
296296
* @memberof Kitsu
297297
* @param {string} model Model to remove data from
298-
* @param {string|number|Array} id Resource ID to remove. Pass an array of IDs to delete multiple resources (Bulk Extension)
298+
* @param {string|number|number[]} id Resource ID to remove. Pass an array of IDs to delete multiple resources (Bulk Extension)
299299
* @param {Object} headers Additional headers to send with the request
300300
* @returns {Object} JSON-parsed response
301301
* @example <caption>Remove a single resource</caption>
@@ -370,7 +370,7 @@ export default class Kitsu {
370370
*
371371
* @memberof Kitsu
372372
* @param {Object} config Request configuration
373-
* @param {Object|Array} config.body Data to send in the request
373+
* @param {Object|Object[]} config.body Data to send in the request
374374
* @param {string} config.method Request method - `GET`, `PATCH`, `POST` or `DELETE` (defaults to `GET`, case-insensitive)
375375
* @param {Object} config.params JSON-API request queries
376376
* @param {Object} config.params.page [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination)

packages/kitsu/types/index.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
export default class Kitsu {
2727
constructor(options?: {});
28-
camel: any;
29-
resCase: any;
28+
camel: (s: any) => any;
29+
resCase: (s: any) => any;
3030
plural: any;
3131
/**
3232
* Get the current headers or add additional headers
@@ -54,7 +54,7 @@ export default class Kitsu {
5454
}, headers?: any) => any;
5555
update: (model: string, body: any, headers?: any) => any;
5656
create: (model: string, body: any, headers?: any) => any;
57-
remove: (model: string, id: string | number | Array, headers?: any) => any;
57+
remove: (model: string, id: string | number | number[], headers?: any) => any;
5858
/**
5959
* Axios Interceptors (alias of `axios.interceptors`)
6060
*
@@ -221,15 +221,15 @@ export default class Kitsu {
221221
*
222222
* @memberof Kitsu
223223
* @param {string} model Model to remove data from
224-
* @param {string|number|Array} id Resource ID to remove. Pass an array of IDs to delete multiple resources (Bulk Extension)
224+
* @param {string|number|number[]} id Resource ID to remove. Pass an array of IDs to delete multiple resources (Bulk Extension)
225225
* @param {Object} headers Additional headers to send with the request
226226
* @returns {Object} JSON-parsed response
227227
* @example <caption>Remove a single resource</caption>
228228
* api.delete('posts', 123)
229229
* @example <caption>Remove multiple resources (API must support the Bulk Extension)</caption>
230230
* api.delete('posts', [ 1, 2 ])
231231
*/
232-
delete(model: string, id: string | number | Array, headers?: any): any;
232+
delete(model: string, id: string | number | number[], headers?: any): any;
233233
/**
234234
* Get the authenticated user's data
235235
*
@@ -261,7 +261,7 @@ export default class Kitsu {
261261
*
262262
* @memberof Kitsu
263263
* @param {Object} config Request configuration
264-
* @param {Object|Array} config.body Data to send in the request
264+
* @param {Object|Object[]} config.body Data to send in the request
265265
* @param {string} config.method Request method - `GET`, `PATCH`, `POST` or `DELETE` (defaults to `GET`, case-insensitive)
266266
* @param {Object} config.params JSON-API request queries
267267
* @param {Object} config.params.page [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination)
@@ -314,7 +314,7 @@ export default class Kitsu {
314314
* })
315315
*/
316316
request({ body, method, params, type, url }: {
317-
body: any | Array;
317+
body: any | any[];
318318
method: string;
319319
params: {
320320
page: {

0 commit comments

Comments
 (0)