Skip to content

Missing types when running in instance mode #132

@xynydev

Description

@xynydev

I'm trying to create a convenience wrapper function for myself to use q5 in a way that suits me better than the default. This wrapper has been previously made for and functioned with p5. The details of the wrapper needn't matter too much, the point is that it requires the use of instance mode.

Current functional minimal functional code using instance mode works is as follows. The setup and draw functions are supplied to the wrapper, q is used as a frontend for q5 (as is officially documented).

let q: Q5 = new Q5("instance");
q.setup = () => {
    setup(q);
};

  q.draw = () => {
    draw(q);
};

This code works and runs without errors. The problem is that the in-editor type validation does not work, as the Q5 type does not actually contain most of q5's functions. Those functions are only declared in types under a global scope. I tried various workarounds to import the global scope of types into a custom named type, but nothing I tried worked for that.

Would it be possible to have a type that includes all the functions and constants of Q5, instead of only having them in the global scope? Or is it somehow possible to import the types from under declare global in q5.d.ts as a single type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions