question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Class specific callbacks

See original GitHub issue

JSDoc defines class-specific callbacks as part of the standard callback convention: https://jsdoc.app/tags-callback.html

They do not appear to work in tsd-jsdoc because it just passes through the ~ character as part of the TS declaration name. As these are meta types, it shouldn’t be too hard to support them.

A naive approach would just be to remove ~ from any identifier when it is encountered during processing, which should work in 99% of the cases.

Another, possible more complete, approach is to change ~ to . and write out the callback function definition as a member of the class the class-specific callback is on.

Is there any reason this would be difficult to add to tsd-jsdoc? I’m happy to submit a pull request with the code and relevant tests if you could point me in the right area of the code to get started.

Thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
glen-84commented, Jun 21, 2020

As a JSDoc yellow-belt, I don’t really understand. Is there a difference in meaning between . vs ~, such that one is “correct” here and the other isn’t? Or are they really synonymous?

According to this:

  • # is used for instance members.
  • . is used for static members.
  • ~ is used for inner members.
0reactions
thw0rtedcommented, Jun 29, 2020

That seems like an oversight in the JSDoc docs. On the @callback page they use ~ as the namepath connector, but on the “About Namepaths” page they do not mention callbacks at all. You could argue that a callback is somehow an “inner member” of a class but really it’s just an “idea” associated with the class, closest to an @interface. Of course, those also use tilde-namepaths in the example, and they’re also conspicuously absent on the namepath page, so 🤷

Read more comments on GitHub >

github_iconTop Results From Across the Web

Callbacks Classes - Verification Academy
The uvm_callback class is the base class for user-defined callback classes. Typically, the component developer defines an application-specific callback class ...
Read more >
Base Callback class - Keras
Abstract base class used to build new callbacks. Callbacks can be passed to keras methods such as fit , evaluate , and predict...
Read more >
How can I pass a class member function as a callback?
This is a simple question but the answer is surprisingly complex. The short answer is you can do what you're trying to do...
Read more >
Chapter 15. Callbacks, hooks, and runtime introspection
Thus you can rig a module so that a particular method gets called every time a class includes that module, or write a...
Read more >
Class Methods for Graphics Callbacks - MATLAB & Simulink
There is a specific syntax necessary to use a method of your class as a callback for MATLAB graphics objects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found