question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Statements inside class property functions are picked up as unused exports

See original GitHub issue

Consider 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:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yamafaktorycommented, Feb 16, 2018

@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!

0reactions
peterjurascommented, Feb 17, 2018

Thanks, your new version fixed this issue! I encountered two more, but I’ll open separate issues for them. Sorry for all the trouble! =)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found