question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript problem?

See original GitHub issue

Primus 7.1.0

Environment:

  • macOS High Sierra
  • Google Chrome Canary
  • Node.js: 8.8.0

I’ve just created a main.ts file with :

import { app, BrowserWindow } from "electron";
import { Primus } from "primus";

let mainWindow: BrowserWindow;

function createWindow() {
  mainWindow = new BrowserWindow({width: 1200, height: 800});

  mainWindow.loadURL("file://" + __dirname + "/index.html");

  mainWindow.webContents.openDevTools();

  const Socket = Primus.createSocket({ transformer: "engine.io", plugin: "primus-emit" });
  const primus = new Socket("http://localhost:2121");

  primus.on("open", () => {
    this.log("Connection opened !");
  });

  mainWindow.on("closed", () => {
    mainWindow = null;
});
}

app.on("ready", createWindow);

app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
  }
});

app.on("activate", () => {
  if (mainWindow === null) {
    createWindow();
  }
});

And I have a compile error with tsc :

$ tsc
src/main.ts(14,18): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.

It is on the Socket but in plain vanilla javascript it is working, i can’t understand? thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yovanoccommented, Oct 28, 2017

Okay, i will take a look closer and open a PR if we have to change the declaration file so

0reactions
yovanoccommented, Nov 1, 2017

I have some news.

For this code in a .ts file:

screen shot 2017-11-01 at 4 24 11 pm

it’s working, but there are some errors dues to the definition file I think:

screen shot 2017-11-01 at 4 24 34 pm
Read more comments on GitHub >

github_iconTop Results From Across the Web

Playground Example - Errors - TypeScript
By default TypeScript doesn't provide error messaging inside JavaScript. Instead the tooling is focused on providing rich support for editors.
Read more >
Issues · microsoft/TypeScript - GitHub
TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Issues · microsoft/TypeScript.
Read more >
The Trouble with TypeScript - DEV Community ‍ ‍
TypeScript doesn't improve productivity or readability. It doesn't particularly improve on modern JavaScript feature set. If anything it ...
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them. ... To fix the problem you have to update the reference path...
Read more >
The problem with Typescript - zackoverflow.dev
The problem with Typescript. Typescript is an amazing project, but a perplexing open-source blackbox. Typescript has one of the most unique type ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found