Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

408
Views
Error: *.default no es un constructor

Recibo el siguiente error, cuando pruebo un código javascript, transpilado de un archivo mecanografiado.

Aquí está el error:

 Error: _mapAction2.default is not a constructor

Aquí está la línea de código que causó el error:

 var mapAction = new MapAction(MapActionType.POLYGONDRAGGED, []);

Aquí está el map-action.ts del archivo mecanografiado original:

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

Aquí está el archivo .js map-action.js transpilado :

 "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
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Debe exportar un valor predeterminado que se verá así:

 export default class MapAction implements IMapAction {...

E importarlo como:

 import MapAction from './map_action_file';

Alternativamente, si desea exportar varias cosas desde el módulo, puede hacer algo como:

 export class MapAction ... export class MapSomethng ...

E importarlo de la siguiente manera:

 import { MapAction, MapSomething } from './map_action_file';
over 4 years ago · Santiago Trujillo Report

0

Otra solución sería agregar "esModuleInterop": true, en tsconfig.json .

esModuleInterop permite importaciones predeterminadas desde módulos sin exportación predeterminada.

over 4 years ago · Santiago Trujillo Report

0

Comprueba que tu importación es correcta. es posible que te pierdas {} por ejemplo.

 import LatLngLiteral from '';

para

 import { LatLngLiteral } from '';
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!