18
当测试一些JavaScript代码时,从打字稿文件转译出来时出现以下错误。错误:* .default不是构造函数
我该怎么做才能解决这个问题?
以下是错误:
Error: _mapAction2.default is not a constructor
这里是导致错误的代码行:
var mapAction = new MapAction(MapActionType.POLYGONDRAGGED, []);
这里原来打字稿文件地图action.ts :
import { IMapAction} from './imap-action';
import { MapActionType } from './map-action-type.enum';
import {LatLngLiteral} from 'angular2-google-maps/core';
export class MapAction implements IMapAction{
type: MapActionType;
paths: Array<LatLngLiteral>;
constructor(mapActionType: MapActionType, paths: Array<LatLngLiteral>){
this.type = mapActionType;
this.paths = paths;
}
public getType(): MapActionType{
return this.type;
}
public getPaths(): Array<LatLngLiteral>
{
return this.paths;
}
}
这里是transpiled的.js文件地图action.js:
"use strict";
class MapAction {
constructor(mapActionType, paths) {
this.type = mapActionType;
this.paths = paths;
}
getType() {
return this.type;
}
getPaths() {
return this.paths;
}
}
exports.MapAction = MapAction;
//# sourceMappingURL=map-action.js.map
提前感谢!
或替代,进口'{}地图行动从” /无出口默认 – Ksyqo
map_action_file''谢谢YEV,我合并所有MAP_ACTION相关文件合并成一个,然后@ Ksygo的评论修正了错误! – ChristopherMortensen
缺乏{}让我如此:从'./Frak'导入{Frak};'修复了它。谢谢。 – RyanNerd