3 ms·
Granted, I'm a novice in TS/JS world after decades in strongly typed environments so it's possible that I'm doing something wrong. I'm not talking about npm, I
by grujicd 3y ago
Granted, I'm a novice in TS/JS world after decades in strongly typed environments so it's possible that I'm doing something wrong.
I'm not talking about npm, I experienced these issues in my own code. It's mostly related to ts transpilers. They're fast, they're used in build systems which should be latest and greatest (e.g. Vite), but they're not robust, they don't always catch type changes in dependent files. And now I can't just change a type and rely on compiler to check ALL occurrences in entire code base. Because it's not really a compiler but a transpiler and it misses some things. Also, tsc doesn't seem to handle jsx/tsx, is there a way to perform real type script compilation with full type checks on tsx files?
- rezonant 3y agoSounds like you are talking about frontend development. In that case you are trading off speed for accuracy. Some dev server tooling has this issue. Most systems built on Vite though do check across files, so likely that's just a bug in the build system you were using. A bug that is likely fixed. One thing you can be assured of is that when you actually build your app (hopefully using CI), it will find those problems, because you are not relying on hot reloading to do it. On the backend side it's far less common to use a build server model, and personally not very warranted -- building a frontend app can take a lot of time and the feedback cycle needs to be short for a dev to be effective. On the backend, a small amount of time rebuilding the app before it is rerun is not nearly as costly. If your Typescript codebase is so large that the feedback cycle of rebuilding is too long, well you have to take the tradeoff, but it's a rare problem. Understand that the only way a "dev server" style backend build process is saving you time is by not checking the types during recompilation. It wouldn't be surprising that it would miss typing changes.
- grujicd 3y agoYes it's for the frontend, but it's not really related to hot reload thing. Is there a way to really compile tsx? I couldn't find any, tsc doesn't support it so you have to use some of the transpilers, and they don't perform full type check across files. So there's no way to perform real "full build" when tsx files are used, even if you don't care about build duration. If there is, I would love to hear about it.
- deleted 3y ago[deleted]