I am most probably missing some tsconfig option here.
What Im doing is pretty simple:
I am creating an npm module, for example:
export class HelloWorld {
constructor(public greeting: string){}
}
with my tsconfig being:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"removeComments": true,
"noImplicitAny": false,
"preserveConstEnums": true,
"declaration": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "../js"
},
"filesGlob": [
"./**/*.ts",
"!./node_modules/**/*.ts"
]
}
When my declaration is automatically created it looks like this:
export declare class HelloWorld {
greeting: string;
constructor(greeting: string);
}
But that doesnt work well when actually installing the npm package in other projects. When I import the package I have to use:
import hello = require("hello-world/js/index");
(for example)
I found out that when I wrap the declaration file in module declare module "hello-world" {...} Then I can import it as desired by import hello = require("hello-world");
Wrapping the generated definition file manually is not an option as it rewrites itself all the time, is there any option that would take name of the package from package.json and automatically wrap the definition in that module?