-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed as not planned
Closed as not planned
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
π Search Terms
"unbound-method", "this {void}", "this: void"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
@this
,this: void
, or "unbound".
β― Playground Link
π» Code
Using @this {void}
:
class Utilities {
/**
* @this {void}
* @param {string} message
*/
static functionThatDoesNotUseThis(message) {
console.log(message);
}
}
/**
* Hovering over the static function here reveals that `this: void` is already applied.
* However, the `@typescript-eslint/unbound-method` error suggests applying it.
*/
const shorthand = Utilities.functionThatDoesNotUseThis;
With a function signature type:
class Utilities {
/**
* @type {(this: void, message: string) => void}
*/
static functionThatDoesNotUseThis(message) {
console.log(message);
}
}
const shorthand = Utilities.functionThatDoesNotUseThis;
With a separate .ts
file and JSDoc import:
// types.ts
export type DoThingFunction = (this: void, message: string) => void;
// Main script
class Utilities {
/**
* @type {import("./types.ts").DoThingFunction}
*/
static functionThatDoesNotUseThis(message) {
console.log(message);
}
}
const shorthand = Utilities.functionThatDoesNotUseThis;
π Actual behavior
ESLint suggests to mark this: void
, despite the editor showing that it already has been.
π Expected behavior
I expect no @typescript-eslint/unbound-method
error when using @this {void}
on a static function and assigning it to a variable.
Additional information about the issue
I reported this on the typescript-eslint repo, but it was closed as a TypeScript issue.
Also, when I created the playground (from the TypeScript ESLint issue template), the this: void
was visible in the static function's signature when hovering over it. But, when I return to the link, it isn't, and the config tabs are not accessible. So, your mileage may vary with the playground.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created