Question

I am trying to convert my project that has NodeJS + ExpressJS to Typescript.

I got the definition files from Definitely Typed, but they seem to have plenty of errors:

export interface ClientRequest extends events.NodeEventEmitter, stream.WritableStream    
{
    // Extended base methods
    write(str: string, encoding?: string, fd?: string): boolean;
    write(buffer: NodeBuffer): boolean;

    write(chunk: any, encoding?: string): void;
    end(data?: any, encoding?: string): void;
    abort(): void;
    setTimeout(timeout: number, callback?: Function): void;
    setNoDelay(noDelay?: Function): void;
    setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
}

export interface Server extends net.Server {
    // Extended base methods
    listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void;
    listen(path: string, listeningListener?: Function): void;
    listen(handle: any, listeningListener?: Function): void;

    listen(port: number, host?: string, callback?: Function): void;
    close(): void;
    address(): { port: number; family: string; address: string; };
    addContext(hostName: string, credentials: {
        key: string;
        cert: string;
        ca: string;
    }): void;
    maxConnections: number;
    connections: number;
}

The methods "write" and listen throw the error: "Incompatible override for member of writable stream".

In the app.js file the var app = express(); function throws an error: Method expression is not a function type:

var http = require("http");
var express = require("express");
var expose = require("express-expose");
var fs = require("fs");
var formidable = require("formidable");
var upload = require('Upload');

var app = express();
var HOST = "localhost";
var PORT = 8080;
Was it helpful?

Solution

'incompatible override' - it's a bug in webStorm, please vote for WEB-10239

'Method expression is not a function type:' can't reproduce in WebStorm 7.0.2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top