DEV Community

Rupesh Krishna Jha
Rupesh Krishna Jha

Posted on

Want to write backend in typescript.

Latest comments (7)

Collapse
 
abhinav profile image
Abhinav Kumar

You can use ts-node to develop Node.ts 🤓 applications. Also see deno.

Collapse
 
theaccordance profile image
Joe Mainwaring

It's low friction to adopt. I'm using TypeScript for the microservice architecture of my SaaS product, my backends tend to use Express at the foundation. Writing the backend in TypeScript is fairly low-friction from my experiences, there's a good amount of Type Support for npm packages (ex: @types/express)

I will note, my team has been inconvenienced by incorrect or missing type definitions a couple times with our dependency choices, but it's rare. Ours have been related to dependencies for SAML & OIDC. Know that it's going to happen, and you're going to have to choose between addressing the gaps (tooling, petitioning the dependencies to add it, writing your own), or ignoring/disabling the rule.

Collapse
 
maniflames profile image
Maniflames

The author of nodejs is actually working an improved runtime that will allow you to use typescript on the back-end!

It's not done yet so you should use what rhymes has suggested but it might be interesting to check out:

denoland / deno

A new way to JavaScript

deno

Linux & Mac Windows

A new way to JavaScript.

  • Supports TypeScript out of the box. Uses a recent version of V8. That is, it's very modern JavaScript.

  • No package.json. No npm. Not explicitly compatible with Node.

  • Imports reference source code URLs only.

    import { test } from "https://unpkg.com/deno_testing@0.0.5/testing.ts"
    import { log } from "./util.ts";

    Remote code is fetched and cached on first execution, and never updated until the code is run with the --reload flag. (So, this will still work on an airplane. See ~/.deno/src for details on the cache.)

  • File system and network access can be controlled in order to run sandboxed code. Defaults to read-only file system access and no network access. Access between V8 (unprivileged) and Rust (privileged) is only done via serialized messages defined in this flatbuffer. This makes it easy to audit. To enable write access…

He also gave a talk on why he decided to build deno:

Collapse
 
rhymes profile image
rhymes

Interesting, he basically wrote a more secure version of Node with Rust and TypeScript :D

Collapse
 
maniflames profile image
Maniflames

Yes! I really hope it will take of as a strong alternative to nodejs

Collapse
 
rhymes profile image
rhymes

I don't use JS on the server side but I've seen mentioned here and on Twitter this framework which uses Node and Typescript:

GitHub logo nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications on top of TypeScript & JavaScript (ES6, ES7, ES8) 🚀

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.



NPM Version
Package License
NPM Downloads
CircleCI
Coverage
Discord
Backers on Open Collective
Sponsors on Open Collective

Support us

Description

Nest is a framework for building efficient, scalable Node.js server-side applications. It uses modern JavaScript, is built with TypeScript (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).

Under the hood, Nest makes use of Express, but also, provides compatibility with a wide range of other libraries, like e.g. Fastify, allowing for easy use of the myriad third-party plugins which are available.

Philosophy

In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and backend applications, giving rise to awesome projects like Angular, React and Vue which improve developer productivity and enable the construction of fast, testable, extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers and tools…




Collapse
 
rupeshiya profile image
Rupesh Krishna Jha

Thank @rhymes for sharing this.
I would love to write backend in ts. It would be a wonderful experience.