Skip to content

Commit f1afc0d

Browse files
committed
Fix typing of p5.FileInput and p5.File
1 parent 27c8edd commit f1afc0d

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/dom/dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ function dom(p5, fn){
18711871
* @method createFileInput
18721872
* @param {Function} callback function to call once the file loads.
18731873
* @param {Boolean} [multiple] allow multiple files to be selected.
1874-
* @return {p5.File} new <a href="#/p5.File">p5.File</a> object.
1874+
* @return {p5.Element} The new input element.
18751875
*
18761876
* @example
18771877
* <div>

src/dom/p5.File.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function file(p5, fn){
155155
* object. All `File` properties and methods are accessible.
156156
*
157157
* @for p5.File
158-
* @property file
158+
* @property {File} file
159159
* @example
160160
* <div>
161161
* <code>
@@ -200,7 +200,7 @@ function file(p5, fn){
200200
* For example, `'image'` and `'text'` are both MIME types.
201201
*
202202
* @for p5.File
203-
* @property type
203+
* @property {String} type
204204
* @example
205205
* <div>
206206
* <code>
@@ -237,7 +237,7 @@ function file(p5, fn){
237237
* <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types" target="_blank">MIME type</a>
238238
* may have a subtype such as ``png`` or ``jpeg``.
239239
*
240-
* @property subtype
240+
* @property {String} subtype
241241
* @for p5.File
242242
*
243243
* @example
@@ -273,7 +273,7 @@ function file(p5, fn){
273273
/**
274274
* The file name as a string.
275275
*
276-
* @property name
276+
* @property {String} name
277277
* @for p5.File
278278
*
279279
* @example
@@ -309,7 +309,7 @@ function file(p5, fn){
309309
/**
310310
* The number of bytes in the file.
311311
*
312-
* @property size
312+
* @property {Number} size
313313
* @for p5.File
314314
*
315315
* @example
@@ -347,7 +347,7 @@ function file(p5, fn){
347347
* Data can be either image data, text contents, or a parsed object in the
348348
* case of JSON and <a href="#/p5.XML">p5.XML</a> objects.
349349
*
350-
* @property data
350+
* @property {any} data
351351
* @for p5.File
352352
*
353353
* @example

utils/patch.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ export function applyPatches() {
9393
'createVideo(src?: string | string[], callback?: (video: $1.MediaElement<HTMLVideoElement>) => any): $1.MediaElement<HTMLVideoElement>;',
9494
);
9595

96+
// More callback types
97+
replace(
98+
['p5.d.ts', 'global.d.ts'],
99+
/createFileInput\(callback: Function, multiple\?: boolean\): ([pP]5)\.Element;/g,
100+
'createFileInput(callback: (input: $1.File) => any, multiple?: boolean): $1.Element;',
101+
);
102+
96103
// Type returned objects
97104
replace(
98105
'p5.d.ts',

0 commit comments

Comments
 (0)