Skip to content
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

Typescript declaration files script #7465

Open
wants to merge 8 commits into
base: dev-2.0
Choose a base branch
from

Conversation

diyaayay
Copy link
Contributor

This is based off of #6777 and #6972. WIP.
Maybe an AST based approach could be added to the current script. This still needs to handle a few cases, such as static methods.

Changes:

Screenshots of the change:

PR Checklist

@diyaayay diyaayay changed the title added boilerplate script Typescript declaration files script Jan 12, 2025
@diyaayay diyaayay force-pushed the typescript-declarations branch 2 times, most recently from 2face78 to 35cb018 Compare January 17, 2025 20:52
@diyaayay diyaayay marked this pull request as ready for review January 17, 2025 20:53
@diyaayay
Copy link
Contributor Author

I think this still needs work, the format of the output files, and cases to be handled. But, @davepagurek Do you think this would be the correct approach to bypass tsc and generate .d.ts files.

@davepagurek
Copy link
Contributor

I think that's probably the best way forward, since it seemed pretty hard to get tsc to understand how we're adding to p5 classes dynamically. Looking good so far!

function generateTypeFromTag(param) {
if (!param || !param.type) return 'any';

switch (param.type.type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more complex case you might want to try with is paletteLerp, which has an array of tuples:

* @method paletteLerp
* @param {[p5.Color, Number][]} colors_stops color stops to interpolate from

Ideally that out output basically back out to its original format, or possibly Array<[p5.Color, number]>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paletteLerp wasn't present in dev-2.0 when I last checked it. I see that it's added now so I'll handle the respective case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davepagurek documentation.js does not generate the correct docs.json for paletteLerp. I updated the JSDocs for it and made changes to the code to handle this issue. If paletteLerp is the only case involving an array of tuples and we need to simplify the script, we could also add it directly to patch.js.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What output were you seeing before? I was looking at it recently in #7497 as a test case and the docs.json seemed to be correct (although utils/convert.js had to be updated to handle those cases.)

Copy link
Contributor Author

@diyaayay diyaayay Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"params": [
      {
        "title": "param",
        "name": "amt",
        "lineNumber": 13,
        "description": {
          "type": "root",
          "children": [
            {
              "type": "paragraph",
              "children": [
                {
                  "type": "text",
                  "value": "number to use to interpolate relative to color stops"
                }
              ]
            }
          ]
        },
        "type": {
          "type": "NameExpression",
          "name": "Number"
        }
      }
    ],

@davepagurek If I'm not wrong, the current docs/data.json just generates one object in params i.e. amt. The array of tuples colors_stops just has the following entry in docs/data.json:

 {
        "title": "param",
        "description": "color stops to interpolate from",
        "lineNumber": 12,
        "type": null,
        "errors": [
          "unexpected token"
        ],
        "name": "colors_stops"
      }

@diyaayay diyaayay force-pushed the typescript-declarations branch 2 times, most recently from 19c5fba to 35cb018 Compare January 19, 2025 07:14
@davepagurek
Copy link
Contributor

Hi @asukaminato0721, I also wanted to get your feedback on this! The approach, I think, will end up being pretty similar to p5.ts where we aren't directly running tsc on the code, but hopefully we can set this up in a way that can help us keep things up-to-date more easily.

In the p5.ts implementation, there are also some manual patches that get applied in addition to generating things directly from the docs: https://github.com/p5-types/p5.ts/tree/master/patches @diyaayay we should see if we can update this in p5 itself too if we can.

@diyaayay
Copy link
Contributor Author

Hi @asukaminato0721, I also wanted to get your feedback on this! The approach, I think, will end up being pretty similar to p5.ts where we aren't directly running tsc on the code, but hopefully we can set this up in a way that can help us keep things up-to-date more easily.

In the p5.ts implementation, there are also some manual patches that get applied in addition to generating things directly from the docs: https://github.com/p5-types/p5.ts/tree/master/patches @diyaayay we should see if we can update this in p5 itself too if we can.

Sure, I'll look into all the patches and see how many of these are still applicable on the dev-2.0 branch.

@asukaminato0721
Copy link
Contributor

Hi @asukaminato0721, I also wanted to get your feedback on this! The approach, I think, will end up being pretty similar to p5.ts where we aren't directly running tsc on the code, but hopefully we can set this up in a way that can help us keep things up-to-date more easily.

In the p5.ts implementation, there are also some manual patches that get applied in addition to generating things directly from the docs: https://github.com/p5-types/p5.ts/tree/master/patches @diyaayay we should see if we can update this in p5 itself too if we can.

This looks promise! I like it.

@diyaayay diyaayay marked this pull request as draft January 23, 2025 20:57
@davepagurek
Copy link
Contributor

I just noticed an issue while working on #7497 that exists in the docs parsing, where some methods were being attributed to a class without a p5 prefix (e.g. Framebuffer) while the class itself was being read with a prefix (e.g. p5.Framebuffer). In that PR I manually added back the prefix to resolve the issue. I suspect that you might also need some of the code from that PR in this too.

@diyaayay diyaayay force-pushed the typescript-declarations branch from dc0672d to bb885af Compare January 26, 2025 14:17
@diyaayay diyaayay marked this pull request as ready for review January 27, 2025 18:18
@diyaayay diyaayay force-pushed the typescript-declarations branch from a844230 to 7fab893 Compare February 1, 2025 06:54
@diyaayay diyaayay force-pushed the typescript-declarations branch from 7fab893 to 3b42124 Compare February 1, 2025 07:39
@diyaayay diyaayay force-pushed the typescript-declarations branch from 3b42124 to 3b425b1 Compare February 1, 2025 07:49
@diyaayay
Copy link
Contributor Author

diyaayay commented Feb 1, 2025

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/865080344c6245478418dbb1eca047677e76595a/types/p5/src/events/acceleration.d.ts#L5C1-L6C37

@davepagurek p5.types add this interface for all the functions that do not belong to a class. Should it be defined as an interface that describes fn's properties and methods?

@davepagurek
Copy link
Contributor

davepagurek commented Feb 1, 2025

That's a good question. I guess the reason why there's an instance type is because the variable p5 is also exposed (e.g. so you can write p5.Vector or p5.registerAddon(...)), but that variable isn't the thing that has setup, draw, etc, so we need separate interfaces to describe those two things.

So I think primarily the p5 variable you import is actually a namespace in typescript? But it also is a class because it's newable:

// Import everything
import p5 from 'p5' // p5 is a namespace here
const mySketch = new p5(...) // mySketch is a p5Instance here
const myGraphics = mySketch.createGraphics(...) // myGraphics is a p5.Graphics

// ...but also:
import { Graphics } from 'p5'
console.log(myGraphics instanceof Graphics) // should be true

...so we have to do something to have it both ways.

@diyaayay
Copy link
Contributor Author

diyaayay commented Feb 2, 2025

That's a good question. I guess the reason why there's an instance type is because the variable p5 is also exposed (e.g. so you can write p5.Vector or p5.registerAddon(...)), but that variable isn't the thing that has setup, draw, etc, so we need separate interfaces to describe those two things.

So I think primarily the p5 variable you import is actually a namespace in typescript? But it also is a class because it's newable:

// Import everything
import p5 from 'p5' // p5 is a namespace here
const mySketch = new p5(...) // mySketch is a p5Instance here
const myGraphics = mySketch.createGraphics(...) // myGraphics is a p5.Graphics

// ...but also:
import { Graphics } from 'p5'
console.log(myGraphics instanceof Graphics) // should be true

...so we have to do something to have it both ways.

Would that mean we need both types for p5.js to support both global mode and instance mode, typically requiring two separate TypeScript declaration files?

global.d.ts → Defines everything in global mode (e.g., setup(), draw(), etc.).
index.d.ts → Defines everything in instance mode (e.g., const mySketch = new p5(...)).
@davepagurek

@davepagurek
Copy link
Contributor

The existing types have a separate file, global.d.ts, that they ask you to import if using p5 in global mode: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/865080344c6245478418dbb1eca047677e76595a/types/p5/global.d.ts

We can maybe do something similar adding all the methods in two spots:

// p5.d.ts
declare class p5 {
  // methods here
}

// global.d.ts
declare global {
  interface Window {
    // methods here
  }
}

@diyaayay
Copy link
Contributor Author

diyaayay commented Feb 6, 2025

The existing types have a separate file, global.d.ts, that they ask you to import if using p5 in global mode: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/865080344c6245478418dbb1eca047677e76595a/types/p5/global.d.ts

We can maybe do something similar adding all the methods in two spots:

// p5.d.ts
declare class p5 {
  // methods here
}

// global.d.ts
declare global {
  interface Window {
    // methods here
  }
}

Right, I tried this, and global and instance declarations are picked up from the sketch.

@asukaminato0721
Copy link
Contributor

about the patch, I did some check, patch them all need a lot of effort.

grep "any\[\]" -r ./types/p5/
grep "any\[\]" -r ./types/p5/
./types/p5/global.d.ts:    function clip(callback: (...args: any[]) => any, options?: object): void;
./types/p5/global.d.ts:    function applyMatrix(arr: any[]): p5;
./types/p5/global.d.ts:    function storeItem(key: string, value: string | number | boolean | object | any[]): void;
./types/p5/global.d.ts:    function getItem(key: string): string | number | boolean | object | any[];
./types/p5/global.d.ts:    function changed(fxn: ((...args: any[]) => any) | boolean): p5;
./types/p5/global.d.ts:    function input(fxn: ((...args: any[]) => any) | boolean): p5;
./types/p5/global.d.ts:        successCallback?: (...args: any[]) => any
./types/p5/global.d.ts:    function createFileInput(callback: (...args: any[]) => any, multiple?: boolean): p5.File;
./types/p5/global.d.ts:    function createVideo(src: string | string[], callback?: (...args: any[]) => any): p5.MediaElement;
./types/p5/global.d.ts:    function createAudio(src?: string | string[], callback?: (...args: any[]) => any): p5.MediaElement;
./types/p5/global.d.ts:        callback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (p1: any[]) => any
./types/p5/global.d.ts:        successCallback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        successCallback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        successCallback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/global.d.ts:    function saveJSON(json: any[] | object, filename: string, optimize?: boolean): void;
./types/p5/global.d.ts:    function random(choices: any[]): any;
./types/p5/global.d.ts:        successCallback?: (...args: any[]) => any,
./types/p5/global.d.ts:        failureCallback?: (...args: any[]) => any
./types/p5/global.d.ts:        str: string | object | any[] | number | boolean,
./types/p5/global.d.ts:    function append(array: any[], value: any): any[];
./types/p5/global.d.ts:    function arrayCopy(src: any[], srcPosition: number, dst: any[], dstPosition: number, length: number): void;
./types/p5/global.d.ts:    function arrayCopy(src: any[], dst: any[], length?: number): void;
./types/p5/global.d.ts:    function concat(a: any[], b: any[]): any[];
./types/p5/global.d.ts:    function reverse(list: any[]): any[];
./types/p5/global.d.ts:    function shorten(list: any[]): any[];
./types/p5/global.d.ts:    function shuffle(array: any[], bool?: boolean): any[];
./types/p5/global.d.ts:    function sort(list: any[], count?: number): any[];
./types/p5/global.d.ts:    function splice(list: any[], value: any, position: number): any[];
./types/p5/global.d.ts:    function subset(list: any[], start: number, count?: number): any[];
./types/p5/global.d.ts:    function int(ns: any[]): number[];
./types/p5/global.d.ts:    function boolean(ns: any[]): boolean[];
./types/p5/global.d.ts:    function byte(ns: any[]): number[];
./types/p5/global.d.ts:    function char(ns: any[]): string[];
./types/p5/global.d.ts:    function join(list: any[], separator: string): string;
./types/p5/global.d.ts:    function nfs(nums: any[], left?: number, right?: number): string[];
./types/p5/global.d.ts:    function buildGeometry(callback: (...args: any[]) => any): p5.Geometry;
./types/p5/global.d.ts:        successCallback?: (...args: any[]) => any,
./types/p5/global.d.ts:        failureCallback?: (...args: any[]) => any
./types/p5/global.d.ts:    function userStartAudio(elements?: Element | any[], callback?: (...args: any[]) => any): Promise<any>;
./types/p5/global.d.ts:        path: string | any[],
./types/p5/global.d.ts:        successCallback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any,
./types/p5/global.d.ts:        whileLoading?: (...args: any[]) => any
./types/p5/global.d.ts:        callback?: (...args: any[]) => any,
./types/p5/global.d.ts:        errorCallback?: (...args: any[]) => any
./types/p5/src/webgl/p5.Geometry.d.ts:        constructor(detailX?: number, detailY?: number, callback?: (...args: any[]) => any);
./types/p5/src/webgl/material.d.ts:            successCallback?: (...args: any[]) => any,
./types/p5/src/webgl/material.d.ts:            failureCallback?: (...args: any[]) => any
./types/p5/src/webgl/3d_primitives.d.ts:        buildGeometry(callback: (...args: any[]) => any): Geometry;
./types/p5/src/webgl/p5.Framebuffer.d.ts:        draw(callback: (...args: any[]) => any): void;
./types/p5/src/FFT.d.ts:        analyze(): any[];
./types/p5/src/FFT.d.ts:        waveform(): any[];
./types/p5/src/typography/p5.Font.d.ts:        textToPoints(str: string, x: number, y: number, fontSize?: number, options?: object): any[];
./types/p5/src/typography/loading_displaying.d.ts:            successCallback?: (...args: any[]) => any,
./types/p5/src/typography/loading_displaying.d.ts:            failureCallback?: (...args: any[]) => any
./types/p5/src/typography/loading_displaying.d.ts:            str: string | object | any[] | number | boolean,
./types/p5/src/io/files.d.ts:        write(data: string | number | any[]): void;
./types/p5/src/io/files.d.ts:        print(data: string | number | any[]): void;
./types/p5/src/io/files.d.ts:            successCallback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:            successCallback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:            callback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:        loadXML(path: string, successCallback?: (...args: any[]) => any, errorCallback?: (...args: any[]) => any): XML;
./types/p5/src/io/files.d.ts:        loadBytes(file: string, callback?: (...args: any[]) => any, errorCallback?: (...args: any[]) => any): object;
./types/p5/src/io/files.d.ts:            callback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:            callback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:        httpGet(path: string, callback: (...args: any[]) => any, errorCallback?: (...args: any[]) => any): Promise<any>;
./types/p5/src/io/files.d.ts:            callback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:            callback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:            callback: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:            callback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:            callback?: (...args: any[]) => any,
./types/p5/src/io/files.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/src/io/files.d.ts:        saveJSON(json: any[] | object, filename: string, optimize?: boolean): void;
./types/p5/src/io/p5.Table.d.ts:        getColumn(column: string | number): any[];
./types/p5/src/io/p5.Table.d.ts:        getArray(): any[];
./types/p5/src/core/p5.Element.d.ts:        mousePressed(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        doubleClicked(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        mouseWheel(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        mouseReleased(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        mouseClicked(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        mouseMoved(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        mouseOver(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        mouseOut(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        touchStarted(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        touchMoved(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        touchEnded(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        dragOver(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/p5.Element.d.ts:        dragLeave(fxn: ((...args: any[]) => any) | boolean): Element;
./types/p5/src/core/transform.d.ts:        applyMatrix(arr: any[]): p5;
./types/p5/src/SoundFile.d.ts:        setPath(path: string, successCallback?: (...args: any[]) => any): void;
./types/p5/src/SoundFile.d.ts:        onended(callback: (...args: any[]) => any): void;
./types/p5/src/utilities/array_functions.d.ts:        append(array: any[], value: any): any[];
./types/p5/src/utilities/array_functions.d.ts:        arrayCopy(src: any[], srcPosition: number, dst: any[], dstPosition: number, length: number): void;
./types/p5/src/utilities/array_functions.d.ts:        arrayCopy(src: any[], dst: any[], length?: number): void;
./types/p5/src/utilities/array_functions.d.ts:        concat(a: any[], b: any[]): any[];
./types/p5/src/utilities/array_functions.d.ts:        reverse(list: any[]): any[];
./types/p5/src/utilities/array_functions.d.ts:        shorten(list: any[]): any[];
./types/p5/src/utilities/array_functions.d.ts:        shuffle(array: any[], bool?: boolean): any[];
./types/p5/src/utilities/array_functions.d.ts:        sort(list: any[], count?: number): any[];
./types/p5/src/utilities/array_functions.d.ts:        splice(list: any[], value: any, position: number): any[];
./types/p5/src/utilities/array_functions.d.ts:        subset(list: any[], start: number, count?: number): any[];
./types/p5/src/utilities/string_functions.d.ts:        join(list: any[], separator: string): string;
./types/p5/src/utilities/string_functions.d.ts:        nfs(nums: any[], left?: number, right?: number): string[];
./types/p5/src/utilities/conversion.d.ts:        int(ns: any[]): number[];
./types/p5/src/utilities/conversion.d.ts:        boolean(ns: any[]): boolean[];
./types/p5/src/utilities/conversion.d.ts:        byte(ns: any[]): number[];
./types/p5/src/utilities/conversion.d.ts:        char(ns: any[]): string[];
./types/p5/src/image/image.d.ts:            callback?: (p1: any[]) => any
./types/p5/src/dom/dom.d.ts:        onended(callback: (...args: any[]) => any): MediaElement;
./types/p5/src/dom/dom.d.ts:        addCue(time: number, callback: (...args: any[]) => any, value?: object): number;
./types/p5/src/dom/dom.d.ts:        changed(fxn: ((...args: any[]) => any) | boolean): p5;
./types/p5/src/dom/dom.d.ts:        input(fxn: ((...args: any[]) => any) | boolean): p5;
./types/p5/src/dom/dom.d.ts:        createImg(src: string, alt: string, crossOrigin?: string, successCallback?: (...args: any[]) => any): Element;
./types/p5/src/dom/dom.d.ts:        createFileInput(callback: (...args: any[]) => any, multiple?: boolean): File;
./types/p5/src/dom/dom.d.ts:        createVideo(src: string | string[], callback?: (...args: any[]) => any): MediaElement;
./types/p5/src/dom/dom.d.ts:        createAudio(src?: string | string[], callback?: (...args: any[]) => any): MediaElement;
./types/p5/src/dom/dom.d.ts:            callback?: (...args: any[]) => any
./types/p5/src/dom/dom.d.ts:        drop(callback: (...args: any[]) => any, fxn?: (...args: any[]) => any): Element;
./types/p5/src/color/setting.d.ts:        clip(callback: (...args: any[]) => any, options?: object): void;
./types/p5/src/math/p5.Vector.d.ts:        static equals(v1: Vector | any[], v2: Vector | any[]): boolean;
./types/p5/src/math/p5.Vector.d.ts:        equals(value: Vector | any[]): boolean;
./types/p5/src/math/random.d.ts:        random(choices: any[]): any;
./types/p5/src/data/local_storage.d.ts:        storeItem(key: string, value: string | number | boolean | object | any[]): void;
./types/p5/src/data/local_storage.d.ts:        getItem(key: string): string | number | boolean | object | any[];
./types/p5/lib/addons/p5.sound.d.ts:        bands: any[];
./types/p5/lib/addons/p5.sound.d.ts:        constructor(path: string, callback?: (...args: any[]) => any, errorCallback?: (...args: any[]) => any);
./types/p5/lib/addons/p5.sound.d.ts:        addImpulse(path: string, callback: (...args: any[]) => any, errorCallback: (...args: any[]) => any): void;
./types/p5/lib/addons/p5.sound.d.ts:        resetImpulse(path: string, callback: (...args: any[]) => any, errorCallback: (...args: any[]) => any): void;
./types/p5/lib/addons/p5.sound.d.ts:        impulses: any[];
./types/p5/lib/addons/p5.sound.d.ts:        constructor(name: string, callback: (...args: any[]) => any, sequence: any[]);
./types/p5/lib/addons/p5.sound.d.ts:        sequence: any[];
./types/p5/lib/addons/p5.sound.d.ts:        replaceSequence(phraseName: string, sequence: any[]): void;
./types/p5/lib/addons/p5.sound.d.ts:        onStep(callback: (...args: any[]) => any): void;
./types/p5/lib/addons/p5.sound.d.ts:        constructor(callback: (...args: any[]) => any, interval?: number | string);
./types/p5/lib/addons/p5.sound.d.ts:        onPeak(callback: (...args: any[]) => any, val?: object): void;
./types/p5/lib/addons/p5.sound.d.ts:        record(soundFile: SoundFile, duration?: number, callback?: (...args: any[]) => any): void;
./types/p5/lib/addons/p5.sound.d.ts:        constructor(freqLow: number, freqHigh: number, threshold: number, callback: (...args: any[]) => any);
./types/p5/lib/addons/p5.sound.d.ts:        userStartAudio(elements?: Element | any[], callback?: (...args: any[]) => any): Promise<any>;
./types/p5/lib/addons/p5.sound.d.ts:            path: string | any[],
./types/p5/lib/addons/p5.sound.d.ts:            successCallback?: (...args: any[]) => any,
./types/p5/lib/addons/p5.sound.d.ts:            errorCallback?: (...args: any[]) => any,
./types/p5/lib/addons/p5.sound.d.ts:            whileLoading?: (...args: any[]) => any
./types/p5/lib/addons/p5.sound.d.ts:            callback?: (...args: any[]) => any,
./types/p5/lib/addons/p5.sound.d.ts:            errorCallback?: (...args: any[]) => any
./types/p5/lib/addons/p5.sound.d.ts:        onended(callback: (...args: any[]) => any): void;
./types/p5/lib/addons/p5.sound.d.ts:        setPath(path: string, callback: (...args: any[]) => any): void;
./types/p5/lib/addons/p5.sound.d.ts:        setBuffer(buf: any[]): void;
./types/p5/lib/addons/p5.sound.d.ts:        addCue(time: number, callback: (...args: any[]) => any, value?: object): number;
./types/p5/lib/addons/p5.sound.d.ts:        waveform(bins?: number, precision?: string): any[];
./types/p5/lib/addons/p5.sound.d.ts:        analyze(bins?: number, scale?: number): any[];
./types/p5/lib/addons/p5.sound.d.ts:        linAverages(N: number): any[];
./types/p5/lib/addons/p5.sound.d.ts:        logAverages(octaveBands: any[]): any[];
./types/p5/lib/addons/p5.sound.d.ts:        getOctaveBands(N: number, fCtr0: number): any[];
./types/p5/lib/addons/p5.sound.d.ts:        start(successCallback?: (...args: any[]) => any, errorCallback?: (...args: any[]) => any): void;
./types/p5/lib/addons/p5.sound.d.ts:        getSources(successCallback?: (...args: any[]) => any, errorCallback?: (...args: any[]) => any): Promise<any>;
./types/p5/lib/addons/p5.sound.d.ts:        set(xVal: number, yVal: number, zVal: number, time: number): any[];
./types/p5/lib/addons/p5.sound.d.ts:        orient(xVal: number, yVal: number, zVal: number, time: number): any[];
w@archlinux ~/g/p5.ts (master)> 

@davepagurek
Copy link
Contributor

I think it's ok if we don't hit all of these immediately -- some are array functions that we are removing in 2.0, and others are in the old p5.sound library that has been rewritten and will live separately in https://github.com/processing/p5.sound.js (which itself will need type info, but we will likely tackle this separately), and others I think are supposed to be there (e.g. the return value of getItem() from local storage.)

We're having some documentation writers come to help out soon in preparation for 2.0, so having this list is great, and we can tell them to add types to things like callback arguments that currently are just Function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants