-
-
Notifications
You must be signed in to change notification settings - Fork 75
Namespace exported function return causing later code to be marked unreachable #127
Comments
Can you please paste in the complete output from ESLint? |
I provide more information here :
And the full output from eslint is:
Do you need any other informations? |
I can reproduce the issue with your example, thanks @blemoine. I will look into this! |
The type guard is actually not relevant... It is the return statement inside an exported function from the namespace that is the key. Here is the minimal example for reproducing the issue:
|
Here is another example: /* eslint-disable no-undef */
namespace foo {
function bar() {
return;
}
//Unreachable code.
function baz() {
return;
}
} I think the problem is that the code analyzer is not creating a new code path when the function ends. Will look into this more tonight, might need to patch eslint or create a new rule in the plugin. |
I spent some more time on this. Not sure why this is the case but if you keep the functions type to FunctionDeclartion the rule works as expected. |
Looks like it was to fix a bug with empty body function in namespaces: Maybe we can have it so if the there is a body to the function we keep the type to FunctionDeclaration. What are your thoughts @JamesHenry |
Makes sense to me that a function declaration remains of node type |
What version of TypeScript are you using?
TypeScript 2.1.4
What version of
typescript-eslint-parser
are you using?[email protected]
[email protected]
What code were you trying to parse?
What did you expect to happen?
With
in my config, I would expect no error (the last line is reachable, because it's exported)
What happened?
I get "Unreachable code no-unreachable" error.
When I remove the type guard function, the problem disappear.
The text was updated successfully, but these errors were encountered: