-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [no-invalid-void-type] false positive on this: X | void annotation #10984
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
Comments
🤔 Interesting, I've seen ponyfills and wrappers for |
I don't remember where I got it from, but probably the idea was you could call |
I'm not sure I understand, when you say "but probably the idea was you could call withResolvers()" -- what do you mean "probably"? How are you using it? If you don't intend to use the |
Argh, can we focus on thoroughness? I copy pasted the code, thought |
That's what we're trying to do 😄. You've posted an issue with some context and a partial explanation that we're interested in hearing more about. We can't reasonably take action until we understand:
It's that we want to be thorough and understand something fully before jumping to action and applying a potentially insufficient -or even wrong- solution. As with #10982, help us help you. The better you can explain why you want a thing to happen, the more we can help in making it happen.
By the way, we do really appreciate you reporting this. For every one report there are almost always scores of people who just rolled their eyes and moved onto something else with a workaround / disable comment. Thank you for working with us! ❤ |
I certainly have alternatives here -- my main goal is to cut down on everyone's time spent dealing with nuisance errors, especially when turning on My thinking is just, do I know why someone would need to type a function that may or may not be called with a specific I can understand an argument that overloading |
We're not blowing it off for being niche. We're trying to understand what the purpose of it is, to evaluate how best to support it. Please give us the information we're requesting so we can help support the use case you're requesting. Or, if you don't have that information, let someone who does post so we can have a productive discussion. Thanks! |
Removing the explicit
Because I was trying to churn through a bunch of |
Great, glad it all worked out! 🙂 |
@JoshuaKGoldberg I actually closed it by accident haha. I'm getting too bent out of shape so I should move on, but I hope you can understand that this has been frustrating for me, trying to solve a |
Sure, I can understand that. It sounds very frustrating! If you have the time, I'd love to know - is there anything you think we could have done to signal that we're just requesting info, not pushing back? I'm reading back through the messages and am missing where the perceived pushback is coming from. My intent here was just to learn more about the use case, not to try to indicate to you it's wrong. No worries if you don't have the time to keep engaging though 🙂 |
It was mainly Brad saying "How are you using it?... why not just ditch it..?" For me it's like, imagine if you have some parser error out on weird but valid syntax. You work around it and report an issue, but then the parser maintainer says "why are you even using this weird syntax anyway?" It's beside the point, you never ever want a parser to fail to parse valid syntax. Not a perfect analogy because things aren't so cut and dry in the world of TypeScript and linting. But I wish |
Gotcha, thanks - I appreciate the perspective. But, I do want to push back on your interpretation of Brad's questions. You're right that things aren't cut and dry in the world of linting. Rules like I empathize that this can easily come across as gruff pushback, even avoidance of responsibility or work on our end. But asking a reporter why they are using it and why they don't ditch it are reasonable and valid questions in this line of work. Both are necessary to understand that why. In other words: this is how it works for us 😄 we need to ask those questions, otherwise we're not doing our jobs. |
Just to document the technical resolution to this, which is somewhat duplicated in the discussion in #10982, the function unsafe(this: void | PromiseConstructor): void {
if (this != null) {
console.log(this.all.name);
}
}
function unsafelyReturnsVoid(cb: () => void): void {
return cb();
}
const randomObject = unsafelyReturnsVoid(() => ({ random: 'object ' }));
unsafe.call(randomObject); // runtime error: property 'name' does not exist on undefined. It's probably a bit of a niche threat since I think you more or less have to use Might make sense to consider a behavior change if a compelling use case is demonstrated. |
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.7.2&fileType=.tsx&code=KYDwDg9gTgLgBDAnmYcAKUIFsCWBnYAdRxgAsAlYPCAGwDdgo8AeAFQD44BeOAbwCg4cAPTC4AOkn8Avv37CAVAsEK4AVQJQaAQwB2AEzg4sYGsCzBdMbTBwRdcCADM4AbQzZ8wcQHcSFKloGJgBdXgABGhxdAGs4UhgYMDwALlF9YAYaCBQocSwIAC8cGh1xaABzYUsAWjUAZWF9CABjPGFCYAAjYQApbTptepaoHDAYYUonRksW4GEAcWyu7RoAfQB5LoArYBaYdo9cAmE-MkpqekY8aXEVOA3dObgfVABXMAqobQyECDgAHIQX4AJhBABoXqgWno4Hgzi1SH8EKRUF03iVbLo7nAFMJ%2BKBILA4E43k9bPYXv4LkFrmx2AAKQQo-ApdCYY7AADC9jwMCgb320DgAB84HQIDh9PwAJRso5eYjnQJXJj0vjMqDAGBvKAOARCISiCRSISyWRAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1uYDcBDRgBNaPDpWFFS6KImjQO0SODABfECqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
No error
Actual Result
void is not valid as a constituent in a union type 10:30 - 10:34
Additional Info
This is the only possible way to type an optional
this
binding other than function overloads, but function overloads trigger@typescript-eslint/unified-signatures
.The text was updated successfully, but these errors were encountered: