Let's consider this code :
class Foo {
type;
constructor(type) {
this.type = type;
}
foo() {
this.type === 'animation' ? create() : createNoop();
}
}
new Foo('animation')
function create() {
console.log('create');
}
function createNoop() {
console.log('create Noop')
}
It there a way to refactor this, in order to get createNoop() tree shaken.
The key here is that type is meant to be readonly once it has been set by the constructor.