205 points · by 0xedb · 4y ago · 100 comments
Does anyone else have a better solution shared Typescript code?
One of the first lines in the deno docs is:
> Deno has no "magical" module resolution.
Which, as an implementor of module system rules, seems incredibly far from the truth of the matter (where deno has the most complex resolution rules of any runtime currently in use). I think maybe there were simple goals at the start, but that came crashing against reality and xkcd 927 executed in full force.
We have been adding a Node.js compatibility mode, but I am not sure that qualifies as "_very_ custom module resolution".
Both the triple-slash reference and @deno-types were solutions to problems to not have opaque type resolution with TypeScript. They do not impact the runtime resolution, only the type check resolution. Instead of opaquely searching for these by reading the `package.json` and probing the file system like `tsc`, Deno is explicit.
I would be glad to work with you to explore how we can figure out how to resolve your implementor concerns. The door has been open for a long time, and I have mentioned it in passing to Daniel a couple times. Let me know if you would like to talk.
One solution is to use an import map on the Deno side to map your extensionless imports to the corresponding files, but this only works when you control the Deno command line arguments (so not for libraries you plan to publish for others to use).
It’s unfortunate because, other than this huge problem, Deno is the best TypeScript runtime I’ve found.
I may be nitpicking here, but Deno isn't a typescript runtime, is it? In the usual case, does it not transpile typescript to JavaScript and run the code from there?
Is Node really a JavaScript runtime? V8 converts the JS to an AST. Would that make Node an `AST runtime`?
Still a hack, but perhaps symlinks could be a little simpler?
I think what you are missing is that, if you use TypeScript in Deno, the extension is .ts. What's confusing is the way Node.js+TypeScript does it, which means using TypeScript with .js extensions.
"They" dropped Angular altogether: https://blog.angular.io/finding-a-path-forward-with-angularj...
To each their own, but I think life's too short to be adding types to your view logic and your templates. It adds so much complexity for so little gain. Maybe it'll get better at some point where it will change my mind, in particular when using something like Deno.
Server sends data as JSON to the client. Client parses JSON. Both now have the exact same data shape. Shared TS types let you use the same representation for the same data no matter where.
No, not really. Clients are loosely coupled, but they must comply with a contract.
And guess what: contracts define types, and REST focuses almost exclusively on types.
Under the architecture I describe, no, clients and servers do not couple to one another. The client and server couple to a data interchange format.
> contracts define types
Yes, the interchange format defines the types for the interchange. But a string can be represented as an enumeration or a float or an integer or a boolean. The type of the data is dependent on context.
> REST focuses almost exclusively on types
In a sense yes, but it also focuses on decoupling clients and servers. The types are really more of an implementation detail. The type of interchange can be XML, HTML, JSON, bytes, text, etc. The fields in a JSON document can all be strings for the purposes of interchange but may be parsed to integers and floats for the purposes of rendering the data to the user. The server may parse those fields differently.
Its not relevant to the client or the server how the other chooses to interpret the data. All that matters is that the interchange format is maintained.
Then they had "url" imports, but now they're adding npm compatibility. At that point people will just keep publishing on npm, so I don't see why I should go to the trouble of switching to Deno.
- Testing framework
- Linter
- Bundler
- Formatter
It’s like having Cargo or Go’s CLI for JavaScript/TypeScript. It eliminates so much fiddling and breakage, gets everyone in the ecosystem on the same page, etc. Even for a solo project it’s been a dream to use, compared with the hodgepodge of a Node project.
As a frontend dev by day, trying to write services/scripts in Node is constantly frustrating. Simple things like base64 encoding or making http requests have me heading off to the documentation and trying to remember "the Node way".
The other large part for me is the lack of npm. The npm ecosystem is one of my largest sources of daily frustration. I look forward to ESM everywhere.
Now, I see another new app for a different purpose being started and I hoped to push for a modern way of building it, but no they just won't give-up using java and JSF.
Nothing wrong with java, it's just java and jsf crowd is hard to be converted to something else.
I gave up after searching around for a few minutes and learning that for now I'd need to use VS Code to write Deno code, if I want those features.
1) The documentation for the standard APIs is extremely wanting. The main, and weirdest, problem is that it seems almost impossible for search engines to index (or at least DDG). I can search for very very specific things, and still get kicked to the home page and have to manually navigate to the part I’m looking for (and the navigation is also pretty difficult; I often can’t find the thing at all and have to rely completely on editor hover-overs for documentation). It can also be confusing- some things like certain standard APIs appear to have multiple conflicting reference-manuals? And it can be hard to know which one is current or correct. Even getting past all the obfuscation, the docs are just ok. They often leave out deeper details (this last part is less of a problem and more understandable, this being a young project).
2) The VSCode extension still needs work. It’s usable, and better than nothing, and it’s better than it used to be, but (ordered from most to least significant):
- When I open certain files - usually bundles or something; maybe files outside of the project directory? - the language server crashes over and over and over, each time popping the terminal back up to show the output and distracting from what I’m trying to look at. This doesn’t happen with my normal, in-project Deno files at least.
- It doesn’t have auto-import as you’re typing like normal TypeScript does; you can auto-import by clicking the lightbulb, so I assume it’s a relatively short hop to plug that in. Makes a significant difference in flow.
- It chokes on absolute import-paths in Windows. Thinks they’re malformed remote URLs.
- It has caching issues sometimes. I’ll change some type in one file and other files won’t get the updated type until I close and re-open them, or sometimes the whole editor. This is uncommon so it’s not a huge deal.
I list these criticisms because I want to see Deno succeed. Switching from using TypeScript on Node (with the build steps/configuration, ad-hoc testing and linting, and Node’s pathological legacy APIs) to Deno was a huge quality of life improvement, even with all these problems. Brought to its full potential, I think Deno could be a revolution.
Leaving out details, for the most part, is the right approach for now, I think. Only Node/JavaScript veterans should probably be using Deno for the time being. But I definitely hope Deno can eventually take over and make Node obsolete.
> 2) The VSCode extension still needs work. It’s usable, and better than nothing, and it’s better than it used to be, but (ordered from most to least significant)
At this point, I've kind of given up on VS Code language/runtime extensions in general. Virtually none of them work with the slightest variation in toolchain configuration, whether it's C++ or Typescript or even ESLint. You're lucky if they don't slow the heck down over time. Import paths are the worst! Somehow that's something I inevitably run into, again, no matter the language.
I kinda want to blow all this stuff up and start over. Maybe Deno is a part of that equation. haha
Inventing Node before Deno. Creating a compatibility mode in Deno to run Node scripts instead of a tool to port Node scripts to Deno. They even maintain a tool to convert Deno scripts to Node. You really can’t get it more backwards!
I sometimes look at his GitHub issues and PRs and wrong ideas are not rare. Thankfully he assembled a good team that double checks him and catches most of those wrong ideas. But they can only catch so many, and it’s likely more difficult for the executive decisions of the Deno company since money is directly involved like creating a Node compat mode.
The backend market is already leaned toward Go. It's the best language for microservices. We also have WASM entering the scene on the frontend side, which allows mixing other languages, especially Rust. Hell, I heard some people ported a whole C++-based UI engine to make it cross-platform. We're already entering the next generation.