“绝对键入”NodeJS + Express定义文件有错误

时间:2013-12-11 09:46:15

标签: node.js express definitelytyped

我正在尝试将具有NodeJS + ExpressJS的项目转换为Typescript。

我从Definitely Typed获得定义文件,但它们似乎有很多错误:

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;
}

方法“write”和listen抛出错误:“不可写的覆盖成员的可写流”。

在app.js文件中,var app = express();函数抛出错误:方法表达式不是函数类型:

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;

1 个答案:

答案 0 :(得分:2)

'不兼容的覆盖' - 这是webStorm中的一个错误,请投票给WEB-10239

'方法表达式不是函数类型:'无法在WebStorm 7.0.2中重现