by danenania · 8y ago · 0 comments
A few questions for TS veterans:
- With babel, we used the module-resolver plugin to set a custom root for absolute imports. In TS, it seems relative imports (import x from '../../../i-hate-life') are the norm, which turns ugly fast. How are folks dealing with this? Or aren’t they?
- Our codebase uses Ramda heavily for FP, and it can be hard to get TS to play nicely sometimes. Any tips on how to most effectively do Ramda/FP in TS?
- Am I missing out by not switching to VSCode? I’m using ST3 currently and it works, but there’s no fancy intellisense. Are the benefits worth picking up a new editor for?
Well... typescript comes with tsserver, which is a local language-server (a Typescript LSP-server), which is what VSCode uses to provide all that goodness.
If you find a LSP-plugin for your favorite editor, it should thereotically be able to offer the same.
For instance, Emacs has tide[1] which uses tsserver (just like VSCode) to provide the same functionality.
I’d be surprised if there were no LSP or tsserver-clients for ST3. No need to leave something you know well over a single feature it may actually support.
https://www.typescriptlang.org/docs/handbook/module-resoluti...
- https://github.com/dividab/tsconfig-paths - resolves paths aliases at runtime in Node
- https://github.com/duffman/tspath - run after build, it rewrites the imports in the resulting JavaScript files
The tuple improvements should be quite exciting for many FP/FP-ish libraries in TS.
See: https://decembersoft.com/posts/say-goodbye-to-relative-paths...
Here's an example:
// tsconfig.json
...
"paths": {
"#src/*": ["src/*"],
}
...
// package.json
...
"requireRewrite": {
"map": [
[
"#src/",
"dist/src/"
],
]
}
...
// src/path1/x.ts
import { X } from '#src/path2/y.ts`I would say yes! VSCode also has many other things to offer over ST3 besides IntelliSense btw.
* Git integration: You can directly edit in diffs, commit from the sidebar, see your submodules and commit in them, ...
* Integrated terminal which can also run tasks, so colors and input will work
* Much better debugging support (AFAIK ST3 has none out-of-the-box)
It's been a while since I've seriously used Sublime Text though.
What's nice about Ramda is that while it uses the Haskell-ish vocabulary and type signatures in its docs, someone can also just dive in and start using it as if it were an underscore-like library and not worry about all the more cerebral stuff.