编译错误打字稿到Javascript

时间:2017-11-03 16:55:32

标签: javascript typescript

我正在Node.js编写Typescript程序,之后我正在编译它以转换ES5 Javascript但在编译期间我正在关注error while using inheritance mechanism

  

ReferenceError:未在javascript文件中定义BaseDatastore

import BaseDatastore = require('./base-datastore');

class Datastore extends BaseDatastore {
    constructor(request: Request, response: Response) {
        console.log('method', request.method);
        super(request, response);
    }
}
export = Datastore;

我的基类是:

'use strict';

class BaseDatastore {
    constructor(request: Request, response: Response) {
        this.execute(request, response);
    }
    execute(request, response) {
        switch (request.method) {
            case 'POST': this.create(request, response);
                break;
            case 'PUT': this.update(request, response);
                break;
            case 'DELETE': this.delete(request, response);
                break;
            case 'GET':
                this.retrieve(request, response);
                break;
            default: console.log('No action taken');

        }
    }
}
export = BaseDatastore;    

我的编译Javascript文件在这里

var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var Datastore = (function (_super) {
    __extends(Datastore, _super);
    function Datastore(request, response) {
        console.log('Hola', request.method);
        _super.call(this, request, response);
    }
    return Datastore;
})(BaseDatastore);// This is the error point
module.exports = Datastore;

我刚刚开始学习Typescript并且我不知道我在哪里做错了

谢谢!!

0 个答案:

没有答案