Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CdkDialogContainer: can no longer simply be extended #26071

Closed
1 task done
jambudipa opened this issue Nov 23, 2022 · 7 comments
Closed
1 task done

CdkDialogContainer: can no longer simply be extended #26071

jambudipa opened this issue Nov 23, 2022 · 7 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@jambudipa
Copy link

jambudipa commented Nov 23, 2022

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14.2.5

Description

Extending CdkDialogContainer now yields the following error:

error NG2016: The component DialogContainerComponent inherits its constructor from CdkDialogContainer, but the latter has a constructor parameter that is not compatible with dependency injection. Either add an explicit constructor to DialogContainerComponent or change CdkDialogContainer's constructor to use parameters that are valid for DI.

Reproduction

This is the unmodified code from the 14.2.5 version of the CDK which worked fine:

import { Component } from '@angular/core';
import { CdkDialogContainer } from '@angular/cdk/dialog';

@Component({
  selector: 'app-dialog-container',
  templateUrl: './dialog-container.component.html',
  styleUrls: ['./dialog-container.component.css']
})
export class DialogContainerComponent extends CdkDialogContainer {
}

Expected Behavior

Should compile without errors.

Actual Behavior

error NG2016: The component DialogContainerComponent inherits its constructor from CdkDialogContainer, but the latter has a constructor parameter that is not compatible with dependency injection. Either add an explicit constructor to DialogContainerComponent or change CdkDialogContainer's constructor to use parameters that are valid for DI.

Environment

  • Angular: 15.0.1
  • CDK/Material: 15.0.0
  • Browser(s): n/a
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS 13.0.1
@jambudipa jambudipa added the needs triage This issue needs to be triaged by the team label Nov 23, 2022
@crisbeto
Copy link
Member

FWIW the CDK dialog container constructor hasn't changed since it was introduced. I suspect that the error here started being reported because the Angular compiler settings changed.

@appocalypseltd
Copy link

Care to elaborate? I have changed nothing other than running ng update.

In any case, it seems to be a typing problem, not sure how that would give rise to this issue?

@crisbeto
Copy link
Member

crisbeto commented Nov 24, 2022

I suspect that the angularCompilerOptions defaults have changed either in the Angular CLI or the compiler which caused the error to surface. Either way, this is definitely something we should resolve.

@crisbeto
Copy link
Member

I asked around in the team and it looks like this was a bug in the compiler that will be fixed by angular/angular#48156 in the next release.

@appocalypseltd
Copy link

appocalypseltd commented Nov 25, 2022

How will I know when this fix is publicly available? And is it a case of ng update?

@crisbeto
Copy link
Member

You can see which fixes are out in each release in the changelog https://github.com/angular/angular/blob/main/CHANGELOG.md. It should be released next week.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

3 participants