angulardependency-managementangular-workspace-configuration

angular build compilation error even library is available


I am getting kind of compilation failures while building an app.

node_modules/@mycomp/lib-my-pat/shared/store/selectors/filter.selector.d.ts:5:75 - error TS2304: Cannot find name 'Interval'.

const getDateInterval: import("@ngrx/store").MemoizedSelector<object, Interval, import("@ngrx/store").DefaultProjectorFn<Interval>>;

It says Cannot find name 'Interval'. even it is available. But it is coming through the different library and other libraries also use this Interval and it is working fine inside the app. This library only throws compilation issue by saying this. If I link this problematic library to the app locally and run, it is working without issue.

This Interval is coming through the date-fns library. It has been added as peer dependency to the library and dependency to the application. There are some other libs that also use the same Interval inside the application and those are working fine. How can I resolve this issue?


Solution

  • I got the solution for this issue after trying out some workarounds there.

    It has happened due to date-fns. It is not used inside the application but it has been used in a library.

    In the side library, there are no imports of that Interval that resolve it globally. Interval has been resolved by other modules inside library. Therefore had add import statement inside library to resolve that issue. Then it is visbled to application globally.

    import { Interval } from 'date-fns';