Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

413
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda