I have a working code snippet that currently appears like this:
import { OtherClass } from "other-class"
class VeryLongClass {
}
OtherClass.run(VeryLongClass);
However, I would like to rearrange it to look like this:
import { OtherClass } from "other-class"
OtherClass.run(VeryLongClass);
class VeryLongClass {
}
My goal in reordering this code is to improve visibility and readability by having the call to the run
function at the top of the class. Although this change seems logical, TypeScript generates an error when I move the function call to the top:
Class 'VeryLongClass' used before its declaration.ts(2449)
classes.ts(6, 14): 'VeryLongClass' is declared here.
While I understand the technical reasons for this error, I am also aware of language features such as variable hoisting. Therefore,
It is crucial for this project to include the call OtherClass.run(VeryLongClass)
, but placing it at the end of the class file can lead to oversight, especially in longer files where confirmation is more challenging.