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

Property 'registerMethod' does not exist on type #116

Open
error-four-o-four opened this issue Sep 30, 2023 · 1 comment
Open

Property 'registerMethod' does not exist on type #116

error-four-o-four opened this issue Sep 30, 2023 · 1 comment
Labels
require upstream Need upstream to update

Comments

@error-four-o-four
Copy link

error-four-o-four commented Sep 30, 2023

Hey there,

as the title says, the method 'registerMethod' of the p5 prototype isn't recognized by typescript.
I encountered this issue while running p5 in instance mode. E.g.:

p5.prototype.registerMethod('init', function init(this: p5) {
  console.log('registered');
});
@asukaminato0721
Copy link
Contributor

because p5.js doesn't add type for it

https://github.com/processing/p5.js/blob/cdf8d918ec8df2736ca61f0b72dfe5ccf70b61e8/src/core/main.js#L646

from the code

  registerPreloadMethod(fnString, obj) {
    // obj = obj || p5.prototype;
    if (!p5.prototype._preloadMethods.hasOwnProperty(fnString)) {
      p5.prototype._preloadMethods[fnString] = obj;
    }
  }

  registerMethod(name, m) {
    const target = this || p5.prototype;
    if (!target._registeredMethods.hasOwnProperty(name)) {
      target._registeredMethods[name] = [];
    }
    target._registeredMethods[name].push(m);
  }

registerPreloadMethod will also not exists on type.

@asukaminato0721 asukaminato0721 added the require upstream Need upstream to update label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
require upstream Need upstream to update
Projects
None yet
Development

No branches or pull requests

2 participants