TypeScript problem?
See original GitHub issuePrimus 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:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, i will take a look closer and open a PR if we have to change the declaration file so
I have some news.
For this code in a .ts file:
it’s working, but there are some errors dues to the definition file I think: