-
Notifications
You must be signed in to change notification settings - Fork 889
Undeprecate no-use-before-declare #4789
Comments
This comment has been minimized.
This comment has been minimized.
Because example from issue #2551 is not isolated and contains some project specific entities, I tried to test code from replies: #2551 (comment) export function foo ({ param: p }: { param: any }) {
}
declare let user1: any;
const { email: user1Email, name: user1Name }: { email: string, name: string } = user1; There are no errors with |
@adidahiya do you have more context on why the rule was deprecated? I'm not seeing anything linked by #3520. Edit: for future reference, it's been mentioned as slow as far back as #1261. |
If we take the code from the OP and move const consumer = () => {
console.log(variable);
};
const variable = "foo";
consumer();
Well, no, there's a structural difference between a rule that has an implementation bug verses a rule that has a seemingly-unfixable structural bug. It would be quite a lot of work to make the rule understand that placing If the rule is to be enabled, I think it would be a requirement to clearly mention its shortcomings in the docs per this thread. Thoughts? |
I think it's good tradeoff. In original topic @OliverJAsh mentioned about it. |
This should be covered by the eslint rule: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md Closing as per deprecation timeline in #4534 |
Feature request
Is your feature request related to a problem? Please describe.
Rule
no-use-before-declare
was deprecated in the PR #4695, but as @karol-majewski noticed TypeScript compiler can't detect some errors.For example, the following code:
doesn't produce any error (TypeScript playground), but causes runtime error.
While deprecated
no-use-before-declare
rule detects this error:Describe the solution you'd like
Undeprecate
no-use-before-declare
.Describe alternatives you've considered
File issue to
TypeScript
project as parallel process.The text was updated successfully, but these errors were encountered: