In my globals.d.ts I export multiple functions whose parameters are also functions. An example can be viewed below:
/**
* Does something
* @param {function(string): void} bar - a parameter
* @returns {void}
*/
export function foo(bar: function(string): void): void;
ESLint is showing multiple errors stating that:JSDoc types can only be used inside documentation comments.. I tried fixing this error by removing the types from the function and only stating them in the comments, but then the type of the parameter becomes any (*). I also tried adding the "valid-jsdoc": "off" rule in the .eslintrc.jsonfile, with no success. Is there a way to remove the warning without losing the type of the parameter?
You can't specify parameter type as function(string): void. It's just wrong syntax to define function types in TypeScript.
Instead of:
export function foo(bar: function(string): void): void;
do:
export function foo(bar: (arg: string) => void): void;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With