Omar Huseynov Omar Huseynov - 3 months ago 22
TypeScript Question

TypeScript compiler doesn't recognize exported class

I have following modules in my app:

In Loader.ts:

module Loader {

export default class FLoader {

constructor () {}

// blahblahblah...

}
}


In Renderer.ts:

import Loader from "../Loader";

module Renderer {

export default class FRenderer {

constructor () {}

public SomeFunction(): void {

let myLoader = new Loader(); // error: Cannot use 'new' with an expression whose type lacks a call or construct signature

}

}
}


And I get error noted in the code: Cannot use 'new' with an expression whose type lacks a call or construct signature

I'm following the docs here. What am I doing wrong?

Answer

I think that it should be:

export module Loader {
    export class FLoader {
        constructor () {}

        // blahblahblah...
    }
}

And then:

import * as Loader from "./Loader";

let myLoader = new Loader.FLoader();

At least that works for me.