How to use npm link with a module written using TypeScript for development?
Yes, you need to write your test project in TypeScript as well. After that you need to map the package to the linked module source files in the test project tsconfig
file.
In the compilerOptions
entry of the tsconfig
file add a baseUrl
and a paths
entry like the following the example:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"linked-module-name": ["node_modules/linked-module-name/src"],
"linked-module-name/*": ["node_modules/linked-module-name/src/*"]
}
}
}
Read more about path mapping in the TypeScript docs.
Another option is to have your TS project automatically rebuild using tsc --watch
and then use the compiled code in your project via npm link ../path/to/dep