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

TemplatePortal class signature: possible typo #14584

Closed
mina-skunk opened this issue Dec 20, 2018 · 3 comments
Closed

TemplatePortal class signature: possible typo #14584

mina-skunk opened this issue Dec 20, 2018 · 3 comments
Labels
help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@mina-skunk
Copy link
Contributor

It seems like the TemplatePortal class signature

https://github.com/angular/material2/blob/fe7f95ec10acd9e660f7037be8d006c9e264a57b/src/cdk/portal/portal.ts#L119

should actually be

    export class TemplatePortal<C = any> extends Portal<EmbeddedViewRef<C>> {

and

https://github.com/angular/material2/blob/fe7f95ec10acd9e660f7037be8d006c9e264a57b/src/cdk/portal/portal.ts#L145

should be

    attach(host: PortalOutlet, context: C | undefined = this.context): EmbeddedViewRef<C> {

The generic parameter for Portal is for the type that the attach(host: PortalOutlet): T method returns. That returns what PortalOutlet 's attach(portal: Portal<any>): any; returns. Note: This could be attach<T>(portal: Portal<T>): T; couldn't it If you look at the implementation of PortalOutlet, BasePortalOutlet, it's overload for attach() when passing a TemplatePortal is attach<T>(portal: TemplatePortal<T>): EmbeddedViewRef<T>; not attach<T>(portal: TemplatePortal<T>): T; like you'd expect based on the TemplatePortal class signature.

@jelbourn jelbourn added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent help wanted The team would appreciate a PR from the community to address this issue labels Dec 20, 2018
@jelbourn
Copy link
Member

@gatimus you're right, that is a mistake. Open for PRs if you're interested.

@mina-skunk
Copy link
Contributor Author

Yes, I'll work on that now, just wanted to make sure I saw it right.

mina-skunk added a commit to mina-skunk/material2 that referenced this issue Dec 20, 2018
RudolfFrederiksen pushed a commit to RudolfFrederiksen/material2 that referenced this issue Jun 21, 2019
)

Fixes angular#14584

BREAKING CHANGE
The return type of `TemplatePortal.attach` previously had an incorrect signature:
`TemplatePortal<C>.attach(...): C`. This should actually have been `TemplatePortal<C>.attach(...): EmbeddedViewRef<C>`. The type has been corrected.
@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 Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

3 participants