I have a custom library and a demo project both on angular 7. The library is building fine, the demo project as well and they're also running correctly. The problem happens when I try to build the demo site using the prod tag ng build --prod
. Then I get the warning and error below:
Warning: Can't resolve all parameters for DialogService in /Users/eestein/Documents/dev/sdk-front/node_modules/@proj/components/proj-components.d.ts: ([object Object], [object Object], ?, ?, [object Object], [object Object]). This will become an error in Angular v6.x
Warning: Can't resolve all parameters for ɵa in /Users/eestein/Documents/dev/sdk-front/node_modules/@proj/components/proj-components.d.ts: (?). This will become an error in Angular v6.x
The error:
ERROR in : Can't resolve all parameters for ɵbw in /Users/eestein/Documents/dev/sdk-front/node_modules/@proj/components/proj-components.d.ts: ([object Object], [object Object], [object Object], [object Object], ?, [object Object], [object Object]).
I tracked the warnings and errors down to the offending parts, they are:
1 - First warning:
...
constructor(
private overlay: OverlayService,
private injector: Injector,
@Optional() @Inject(SdkConstants.Dialog.DefaultOptionsInjectionToken) private defaultOptions: DialogConfig,
@Inject(SdkConstants.Dialog.ScrollStrategyInjectionToken) scrollStrategy: any,
@Optional() @SkipSelf() private parentDialog: DialogService,
private overlayContainer: OverlayContainerService
) {
this.scrollStrategy = scrollStrategy;
console.group('dialog');
console.log('defaultOptions', defaultOptions);
console.log('scrollStrategy', scrollStrategy);
console.groupEnd();
}
...
The compiler is complaining it can't resolve defaultOptions and scrollStrategy, even though the first is marked as optional and the second is provided:
export function dialogScrollStrategyProviderFactory(overlay: OverlayService): () => BaseScrollStrategy {
const result = () => overlay.scrollStrategies.block();
return result;
}
...
providers: [
DialogService,
{
provide: SdkConstants.Dialog.ScrollStrategyInjectionToken,
deps: [OverlayService],
useFactory: dialogScrollStrategyProviderFactory
}
]
2 - Second warning (same as error):
constructor(
private dialogService: DialogService,
private overlayService: OverlayService,
private ngZone: NgZone,
private viewContainerRef: ViewContainerRef,
@Inject(SdkConstants.Datepicker.ScrollStrategyInjectionToken) scrollStrategy: any,
@Optional() private dateService: DateService,
@Optional() @Inject(DOCUMENT) document: any
) {
this.document = document;
this.scrollStrategy = scrollStrategy;
console.group('datepicker');
console.log('scrollStrategy', this.scrollStrategy);
console.groupEnd();
}
The compiler is complaining it can't resolve scrollStrategy, even though it is provided.
Output from both console.logs:
As you can see, if I run the demo project and the referred components everything works just fine. It's only when I run ng build --prod
on the demo project I get the build error.
For the past two weeks I have been reading a lot of issues on GitHub and SO questions about "Can't resolve all parameters for ..." and others, but not one seems to be directly related to my problem.
Any ideas on what could be wrong?
PS: Please let me know if more bits of code would help to identify the problem better.
from Getting "Can't resolve all parameters for" only when building demo app for production
No comments:
Post a Comment