I have a local node package written in TypeScript that I want to use in my actual project. Using npm, I can install local packages as follows:
$ npm install
Or:
$ npm install
This installs the necessary .js files in the node_modules directory. It also created the generated .d.ts file inside this package, which I would like to install in my project (automatically linking it to typings / tsd.d.ts). But using the following command has no effect:
$ tsd install /path/to/package/package.d.ts
It says >> zero results . So, what is the way to install local definition files without using a repository?
UPDATE:
I can just copy the d.ts file to the sample directory and my text editor (for me this is Sublime Text with the TypeScript plugin) he can find the ad. The catalog layout looks something like this:
/my-project/ /typings/ tsd.d.ts - auto-generated by `tsd install` node/ - I've installed the node definitions my-package.d.ts - copied or symlinked file my-project.ts - I'm working here
However, I had a problem when exporting a single function to module.exports ( exports = function... in TypeScript). In this case, the exported function is “anonymous” and is not even specified in the d.ts file, so I need to manually edit it.
My test case:
'my-package' provides a single function, usually imported as 'myPackage':
export = function myPackage(a: string, b: string) { return a + ' ' + b; };
declaration set to true in tsconfig.json, so the tsc command generated the file my-package.d.ts:
declare var _default: (a: string, b: string) => string; export = _default;
My package should be used this way in my project:
import myPackage = require('my-package'); myPackage('foo', 'bar');
However, tsc cannot find myPackage , although my-package.d.ts been copied to the sample folder. I need to edit this file so that it looks like this:
declare var myPackage: (a: string, b: string) => string; //export = _default; - not needed
Or even better for require() to function properly:
declare module 'my-package' { export = function(a: string, b: string): string; }