2
votes

I'm having a hard time using the following typings file in my project:

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/log4javascript

Apperantly, the file is missing a module declaration, causing typescript to complain that it can't find the module 'log4javascript' when I put the following statement in my typescript file:

import * as log4javascript from 'log4javascript';

When I manually edit the index.d.ts file that is installed by running the command

typings install dt~log4javascript --global --save

and I add this module declaration:

declare module "log4javascript" { import test = log4javascript; export = test; }

at the end of the file, then the compiler no longer complains and my code even works without using the import * statement.

So how am I supposed to use the typings file so that I can use log4javascript with typescript?

UPDATE

I've managed to work around it by creating a custom.d.ts file which declares the log4javascript module alongside the generated root index.d.ts of typings and added a ///<reference path="..." /> statement in my main.ts file used by requirejs.
I still don't feel that this is the correct way to do it, but it works for now.

1

1 Answers

0
votes

I've managed to work around it by creating a custom.d.ts file which declares the log4javascript module alongside the generated root index.d.ts of typings and added a ///<reference path="..." /> statement in my main.ts file used by requirejs. I still don't feel that this is the correct way to do it, but it works for now.