But not with TypeScript. First off, the refactor tool with IDE (vscode) is much better with TypeScript. Because of TypeScript, IDE refactor tool can help me make the right changes without me going though file name changes manually. Secondly, I would see import error at compile time before running the code. I don’t think checking if code has import errors by running code is reliable because some code do not get run if you don’t visit every page in the app.
When I was using create-react-app with TypeScript, compiling the code would make the import error surface. Now my preferred framework is Nextjs, it only compile one page at time if you run dev mode. In this case, I would use `tsc — pretty — noEmit` command and it will check all the imports in the code comprehensively.
An additionally benefit of TypeScript is when you read codebase, you can see the type of function parameters.
In summary, TypeScript makes refactor much easier and helps you make less mistake during refactor, and make it easier to read codebase.