Skip to content

How to use TypeScript for a custom Node.js server. #13208

Answered by gustavopch
riobits asked this question in Q&A
Discussion options

You must be logged in to vote
  1. You can use something like ts-node, tsx, etc.
  2. You can use Node.js v22.6.0 which has support for TypeScript (or Deno, or Bun).
  3. You can move most server code to entry.server.tsx and import from server.js as I suggest here.
  4. You can simply compile your server.ts file with tsc before running.

I suggest a mix of 1 and 3 or 2 and 3. The third one will avoid a problem that may bite you later. It's described in the linked discussion.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by riobits
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants