I have a package in my node_modules folder which has typings.d.ts and package.json In package.json I set "types": "typings.d.ts"
typings.d.ts
export { T1, T2, T3} from '@somepackage';
interface Window {
additionalProp: any;
}
export declare var window: Window;
And when I'm using this declaration file in some service:
import { window } from '../typings';
export class SomeService {
someMethod(): void {
if (window && window.additionalProp) {
someLogic();
}
}
}
I have no compilation errors But when I build a project, I get next errors:
Module not found: Error: Can't resolve '../typings'
I've read about declare module, triple dash imports, etc. nothing really helped :(
You don't use a relative path with modules in node_modules
. You'd import those types by using
import { window } from "the-package-name/typings";
...where the-package-name
is the name of the package in node_modules
that contains typings.d.ts
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.