Skip to content

Cant export class from a module #3218

@NetanelBasal

Description

@NetanelBasal

I am using typescript 1.5 and common js modules type and when i declare my class inside module i get this error:

client/js/main.ts(4,9): Error TS2305: Module '"client/js/routeController"' has no exported member 'RouteController'.

routeController:

export module myApp {
  export class RouteController {
    $router: any;
    constructor($router) {
      this.$router = $router;

      $router.config([
        { path: '/', component: 'home' }
      ]);
    }
  }
}

main:

import {RouteController} from './routeController';

But when i remove the module and doing this:

class RouteController {
  $router: any;
  constructor($router) {
    this.$router = $router;

    $router.config([
      { path: '/', component: 'home' }
    ]);
  }
}

export default RouteController;

this is working. what is the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions