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

fix: annotate a couple base classes with @Directive for Ivy #17022

Closed
wants to merge 2 commits into from

Conversation

alxhub
Copy link
Member

@alxhub alxhub commented Sep 9, 2019

There are two base classes in Material/CDK which are intended to be extended
by user code: BasePortalHost and MatFormFieldControl.

This commit annotates them with @Directive. The best way to do this is to
use @Directive() but this is not supported by Angular 8.x, on which
Material and the CDK still depend. Therefore, a workaround is used with a
selector which will never be matched. Modules are also added to satisfy the
View Engine compiler.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 9, 2019
// In Angular 9.x, `@Directive()` without any selector is legal (and `BasePortalModule` is not
// necessary either).
// TODO(alxhub): convert to a selectorless Directive when the CDK upgrades to Angular 9.
selector: 'abstract-base-portal-outlet',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you augment this with "do-not-use" as a prefix?

(similar below)

@NgModule({
declarations: [BasePortalOutlet as any],
})
export class BasePortalOutletModule {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DoNotUseBasePortalOutletModule

(similar below)

crisbeto added a commit to crisbeto/material2 that referenced this pull request Sep 29, 2019
Along the same lines as angular#17022. Adds annotations to the various base classes that declare inputs, because the Ivy template type checker doesn't handle base defs at the moment.

Fixes angular#17121.
Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually planned to be a breaking change to most libraries or are there plans to solve this prior to Ivy GA?

Update: Nevermind, it does look like this will be a breaking change for all libraries out there. It will be worst for libraries like Angular Material that aren't built using the Angular CLI and can't use the ng update migrations. Official migration guide: https://angular.io/guide/migration-undecorated-classes

@Splaktar Splaktar added P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release labels Sep 29, 2019
alxhub and others added 2 commits September 30, 2019 08:44
There are two base classes in Material/CDK which are intended to be extended
by user code: BasePortalHost and MatFormFieldControl.

This commit annotates them with `@Directive`. The best way to do this is to
use `@Directive()` but this is not supported by Angular 8.x, on which
Material and the CDK still depend. Therefore, a workaround is used with a
selector which will never be matched. Modules are also added to satisfy the
View Engine compiler.
@jelbourn jelbourn force-pushed the ivy-compat-base-dirs branch from e1dc7e6 to 2ccca29 Compare September 30, 2019 16:10
@jelbourn
Copy link
Member

@alxhub I pushed a new commit to this PR with the names updated and rebased, but there's a legitimate failure.

DomPortalOutlet extends BasePortalOutlet, and DomPortalOutlet is not a directive. I'd ideally prefer not to make it a directive, but it seems like that could be unavoidable. Thoughts?

@jelbourn jelbourn added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful and removed P2 The issue is important to a large percentage of users, with a workaround labels Sep 30, 2019
mmalerba pushed a commit that referenced this pull request Oct 1, 2019
Along the same lines as #17022. Adds annotations to the various base classes that declare inputs, because the Ivy template type checker doesn't handle base defs at the moment.

Fixes #17121.
@mmalerba mmalerba added this to the 9.0.0 milestone Oct 2, 2019
@devversion
Copy link
Member

I'm actually wondering on why we need to decorate these classes with @Directive. These classes do not seem to declare class members with Angular decorators, nor do they use dependency injection.

It doesn't match my understanding of which classes need to be migrated according to our migrations /and migration guides. Can you help explaining this @alxhub?

mmalerba pushed a commit that referenced this pull request Oct 8, 2019
Along the same lines as #17022. Adds annotations to the various base classes that declare inputs, because the Ivy template type checker doesn't handle base defs at the moment.

Fixes #17121.

(cherry picked from commit 8c98013)
crisbeto added a commit to crisbeto/material2 that referenced this pull request Oct 21, 2019
This is a resubmit of angular#17022, excluding the portal changes. It marks the `MatFormFieldControl` as a directive because it's being extended by other directives which can cause errors under Ivy.
crisbeto added a commit to crisbeto/material2 that referenced this pull request Oct 21, 2019
This is a resubmit of angular#17022, excluding the portal changes. It marks the `MatFormFieldControl` as a directive because it's being extended by other directives which can cause errors under Ivy.
mmalerba pushed a commit that referenced this pull request Oct 21, 2019
This is a resubmit of #17022, excluding the portal changes. It marks the `MatFormFieldControl` as a directive because it's being extended by other directives which can cause errors under Ivy.
mmalerba pushed a commit that referenced this pull request Oct 21, 2019
This is a resubmit of #17022, excluding the portal changes. It marks the `MatFormFieldControl` as a directive because it's being extended by other directives which can cause errors under Ivy.
@mmalerba
Copy link
Contributor

closing in favor of #17457

@mmalerba mmalerba closed this Oct 21, 2019
@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 Nov 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants