Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9059747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:03:14+00:00 2026-06-16T15:03:14+00:00

I would like to translate my minimalistic server from Coffeescript to Typescript. Here’s the

  • 0

I would like to translate my minimalistic server from Coffeescript to Typescript.
Here’s the original code:

express = require("express")
app=express()
app.use(express.static(__dirname))
app.set("views", __dirname + "/views")
app.set("view engine", "jade")
app.get("/", (req,res)->
        res.render "index")
port = process.env.PORT or 5000
server=app.listen(port)

io=require("socket.io").listen(server)
io.sockets.on("connection", (socket)->socket.emit("news", "data"))

and here’s the Typescript version:

/// <reference path="d.ts/node.d.ts"/>
/// <reference path="d.ts/socket.io.d.ts"/>
/// <reference path="d.ts/express3.d.ts"/>

import express3 = module("express3");
var express = require("express");
var app = express();
app.use(express.static(__dirname));
app.set("views", __dirname+"/views");
app.set("view engine", "jade");

app.get("/", (req, res) => { res.render("index"); });

var port = 5000;
var server=app.listen(port);

import socketio = module("socket.io");
var io=socketio.listen(app);
io.sockets.on("connection", (socket) => { socket.emit("news", "data"); });

Both versions compile to server.js without problems. The generated code has a different style but as far as I can see, the semantics should be the same.
You can take a look at the two output files on pastebin.

coffeescript: http://pastebin.com/38LZhcPZ

typescript: http://pastebin.com/95ABVsB2

The response “index.jade” contains a small unfinished game with RaphaelJs.
Now here’s the problem. If I start the coffeescript generated server.js and open localhost:5000, everything’s fine. The game starts running.

But if I run the compiled typescript version, the game is not started. There’s no problem with opening localhost:5000. The website is served without errors and if I inspect the page source, it’s all there. At first I thought maybe the static file server of express would somehow not work. But when I click on <script src="../scripts/game.js"/> in the page source, the code is there. The game logic is started with window.onload, maybe there’s a problem, but that would seem rather strange.

What can I do ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:03:15+00:00Added an answer on June 16, 2026 at 3:03 pm

    At quick glance it doesn’t seem to be the same code:

    Original and CoffeeScript Generated:

    io = require("socket.io").listen(server);
    

    But your TypeScript code has:

    var io = socketio.listen(app);
    

    If you modify your TypeScript code to the following I think you should be in action:

    var io = socketio.listen(server);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use Google Translate TTS engine from my JavaScript code. It
I would like to translate or 301-redirect urls such as: www.domain.com/example.html to www.domain.com/example Here
I've got some code which I would like to translate into Opengl ES. I'm
I'm creating a web app that I would like to be able to translate
I would like to know how to translate the following code to codebehind instead
I have following code and would like to translate it to linq. Is it
I would like to translate a query like this one: FROM Entity_1 obj WHERE
i would like to translate this request in LINQ to SQL: SELECT * from
I have some Java code and I would like to translate it to C#.
I would like to translate the following C code to C++. FILE *fp =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.