Statements inside class property functions are picked up as unused exports
See original GitHub issueConsider the following example:
// b.js
export default class B {
objectMethod = () => {
if (true) {
}
};
}
// c.js
import B from "./b";
Shrimpit output:
Shrimpit!
> Unused exports
[ { location: 'b.js', name: '/', unnamedDefault: false } ]
The output is correct if objectMethod is written like this:
objectMethod() {
// ...
}
Amazingly enough, the output is also correct if the if condition is “condition” instead of “true”.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Detect dead exports as well as per-module dead code #30517
The compiler will error on unused exports. The compiler should detect dynamic imports if the module path is hardcoded- the compiler already ...
Read more >Documentation - Modules - TypeScript
Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export keyword. StringValidator.ts. ts. export ......
Read more >Announcing TypeScript 4.9 - Microsoft Developer Blogs
"Remove Unused Imports" and "Sort Imports" Commands for Editors. Previously, TypeScript only supported two editor commands to manage imports. ...
Read more >How can I know which parts in the code are never used?
There are two varieties of unused code: the local one, that is, in some functions some paths or variables are unused (or used...
Read more >16. Modules - Exploring JS
An ES6 module can pick a default export, the main exported value. Default exports are especially easy to import. The following ECMAScript 6...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@peterjuras I’ve released another version in order to fix that issue: https://github.com/yamafaktory/shrimpit/releases/tag/v0.18.4. Waiting for your feedback!
Thanks, your new version fixed this issue! I encountered two more, but I’ll open separate issues for them. Sorry for all the trouble! =)