1

I'm new to TypeScript and I'm having a problem loading an es6 javascript module.

I have the following javascript file

//TemplateFactory.js
export class TemplateFactory{
    static getTemplate(module){

    }
}

and I created the following d.ts file

//TemplateFactory.d.ts
declare module "TemplateFactory" {
    export class TemplateFactory {
        static getTemplate(module);
    }
}

However when I import the js module in another ts file I get this error:

File ....TemplateFactory .d.ts is not a module

What am I doing wrong? I'm using TypeScript 1.8

2 Answers 2

2

I've managed to solve this. Here is the code that worked for me:

export declare class TemplateFactory {
    static getTemplate(module: any): void;
}
Sign up to request clarification or add additional context in comments.

Comments

-1

Try this ,

//TemplateFactory.d.ts

declare module TemplateFactory {

    export class TemplateFactory {
        static getTemplate(module);
    }
}

Don't use quotes .

1 Comment

Sorry.. It's not working. I've found the solution and add my own answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.