I'm currently in the process of developing a small npm package collection that includes some helpful utilities for Jasmine testing. The code can be found on my GitHub page https://github.com/DrMueller/MLAH.Testing. At this point, it consists of only 2 functions and a type. I've encountered a bit of confusion regarding how d.ts files are imported: Based on the official documentation:
By default, all visible "@types" packages are included in your compilation. Packages located in node_modules/@types within any parent directory are considered visible; specifically, those within ./node_modules/@types/
This means that creating a type like
export type SpyOf<T> = {
[Method in keyof T]: jasmine.Spy;
};
My assumption was that removing typeRoots would make the jasmine typings accessible, but I still encounter
Error TS2503: Cannot find namespace 'jasmine'.
Taking into consideration other options like include or types, as per the documentation they limit the discovered typings, so omitting them should include all types in node_modules/@types.
The only solution that has worked thus far is manually adding it to each file like so:
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
While this resolves the compilation issue, it causes an exception when the npm package is not in the same relative folder as the code.
Am I overlooking something here, or is jasmine a special type of module?