-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Please add a new "Convert to bound imports" TS refactoring #46047
Comments
I think the biggest issue here is that we don't understand that import * as process from "process";
process.addListener is undefined no matter what module target you’re using, because |
This was a refactoring added in TypeScript 3.0, right? https://devblogs.microsoft.com/typescript/announcing-typescript-3-0/#named-import-refactoring |
@andrewbranch @DanielRosenwasser thanks for replying! I think we're talking about different things. I'm trying to deal with the (new) error caused by unbound function calls that I'm seeing with javascript produced by TypeScript 4.4. @andrewbranch and I discussed it here: #46027 What I'd like is to either
In the interests of Chesterton's Fence, I'd like to properly understand why y'all made this change, though: Andrew pointed me at meeting notes, but the cure seemed worse than the disease... |
@mceachen the error you get with [alt text]
It has always been invalid to write this code in Node, and our CJS emit for this code has exactly the same behavior as Node's ESM behavior—the issue is that we do not prevent you from writing it in any mode. So you’ve turned up two completely separate issues just trying to write this one little piece of code 😄 |
Syntactically speaking, the refactor we offer you is exactly right, and you end up transforming from one invalid form to another invalid form, neither of which are we capable of noticing is invalid, incredibly. But given that the export we see from |
Thanks for the explanation @andrewbranch! I just found these discussions as well: |
Suggestion
🔍 Search Terms
TypeError: Cannot read properties of undefined
✅ Viability Checklist
⭐ Suggestion
It'd be wonderful to support a new refactor action that converts destructed imports (that newly fail under TypeScript 4.4) to an import that avoids unbound function calls:
before
after
📃 Motivating Example
This would greatly reduce the impact from this TypeScript 4.4 change.
💻 Use Cases
See #46027
The text was updated successfully, but these errors were encountered: