koroandr / log4ts

Logging library for TypeScript
MIT License
42 stars 11 forks source link

How to install? #6

Closed bradseefeld closed 8 years ago

bradseefeld commented 8 years ago

This is a bit of noob question, so I apologize. I am coming to TypeScript with Angular2 and I am still working to understand typings. I am not sure how to install this package, complete with the ConsoleAppender, and BasicLayout. Here's what I am doing so far:

npm install log4ts --save
typings install npm:log4ts --save --global

This allows me to import Logger and LoggerConfig:

import { Logger, LoggerConfig } from "log4ts";

But ConsoleAppender, and BasicLayout cannot be found. If I try to add these to my import, I get:

Module 'log4ts' has no exported member 'ConsoleAppender'

Looking at the source, I can see that neither BasicLayout, nor ConsoleAppender are included in the main index.d.ts file. These have their own definition files, however. I assume you structured it this way so that I could import the implementations of the appender/layout I want, and leave the others omitted.

This is where I am stuck. How do I "typings install" those other definitions?

I have tried: typings install npm:log4ts/build/appenders/ConsoleAppender.d.ts --save, which installs this type definition in my typings.json, but I still cannot import.

import { ConsoleAppender } from "log4ts";
import { ConsoleAppender } from "log4ts/ConsoleAppender";

Both of those fail with the same error as before.

My typings.json currently looks like this:

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "log4ts": "npm:log4ts/build/log4ts.d.ts",
    "node": "registry:dt/node#6.0.0+20160720070758",
    "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654",
    "source-map": "registry:dt/source-map#0.0.0+20160317120654",
    "uglify-js": "registry:dt/uglify-js#2.6.1+20160316155526",
    "webpack": "registry:dt/webpack#1.12.9+20160724112410"
  },
  "dependencies": {
    "log4ts": "npm:log4ts/build/appenders/ConsoleAppender.d.ts"
  }
}

The log4ts dependency in my package.json looks like: "log4ts": "^0.4.1"

bradseefeld commented 8 years ago

Was able to get some help on stack overflow: http://stackoverflow.com/questions/38665688/how-to-install-additional-definitions-of-a-typescript-module/38665783