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(core): renderer-to-renderer2 migration not migrating methods #33571

Closed

Conversation

devversion
Copy link
Member

The renderer-to-renderer2 migration currently does not work
properly in v9 because the migration relies on the type checker
for detecting references to Renderer from @angular/core.

This is contradictory since the Renderer is no longer
exported in v9 @angular/core. In order to make sure that
the migration still works in v9, and that we can rely on the
type checker for the best possible detection, we take advantage
of module augmentation and in-memory add the Renderer export
to the @angular/core module.


Before coming up with the augmentation solution, I spent quite some time re-working the
detection to be not based on the ts.TypeChecker. Though, I went with this solution as it gives us
the best detection of the Renderer and doesn't involve reworking the whole detection.

@devversion devversion added area: core Issues related to the framework runtime action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Nov 4, 2019
@ngbot ngbot bot added this to the needsTriage milestone Nov 4, 2019
@devversion devversion marked this pull request as ready for review November 4, 2019 15:09
@devversion devversion requested a review from a team as a code owner November 4, 2019 15:09
return `
import '@angular/core';
declare module "@angular/core" {
class Renderer {}
Copy link
Member

@crisbeto crisbeto Nov 4, 2019

Choose a reason for hiding this comment

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

We aren't compiling the code so maybe it doesn't matter, but wouldn't this technically cause compilation errors for something like someInstance.setElementClass since the Renderer class is empty? Could we do declare const Renderer: any instead or would that also break type checking?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it would cause errors, but since we don't collect diagnostics, the error won't be reported. It shouldn't have an effect on the migration either.

I think switching to any will break since the type checker will then return any if we call getTypeAtLocation.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

packages/core/schematics/utils/typescript/compiler_host.ts Outdated Show resolved Hide resolved
@kara kara unassigned kara and crisbeto Nov 5, 2019
@kara kara removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 5, 2019
@kara kara added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: presubmit The PR is in need of a google3 presubmit and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Nov 5, 2019
@kara
Copy link
Contributor

kara commented Nov 5, 2019

presubmit

The `renderer-to-renderer2` migration currently does not work
properly in v9 because the migration relies on the type checker
for detecting references to `Renderer` from `@angular/core`.

This is contradictory since the `Renderer` is no longer
exported in v9 `@angular/core`. In order to make sure that
the migration still works in v9, and that we can rely on the
type checker for the best possible detection, we take advantage
of module augmentation and in-memory add the `Renderer` export
to the `@angular/core` module.
@devversion devversion force-pushed the fix/core-migration-renderer2-v9 branch from 4d4d711 to 7fd552d Compare November 5, 2019 19:27
@devversion devversion added the action: merge The PR is ready for merge by the caretaker label Nov 5, 2019
@ngbot

This comment has been minimized.

@devversion devversion added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Nov 5, 2019
@devversion
Copy link
Member Author

Caretaker: Failure for integration_test seems unrelated to this PR. I rebased on top of 44623a1 (latest commit in master).

@kara kara removed the action: presubmit The PR is in need of a google3 presubmit label Nov 5, 2019
@atscott
Copy link
Contributor

atscott commented Nov 5, 2019

Presubmit failures are also unrelated. Still need to investigate the integration_test failures

@atscott atscott closed this in d751ca7 Nov 5, 2019
atscott pushed a commit that referenced this pull request Nov 5, 2019
)

The `renderer-to-renderer2` migration currently does not work
properly in v9 because the migration relies on the type checker
for detecting references to `Renderer` from `@angular/core`.

This is contradictory since the `Renderer` is no longer
exported in v9 `@angular/core`. In order to make sure that
the migration still works in v9, and that we can rely on the
type checker for the best possible detection, we take advantage
of module augmentation and in-memory add the `Renderer` export
to the `@angular/core` module.

PR Close #33571
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…ular#33571)

The `renderer-to-renderer2` migration currently does not work
properly in v9 because the migration relies on the type checker
for detecting references to `Renderer` from `@angular/core`.

This is contradictory since the `Renderer` is no longer
exported in v9 `@angular/core`. In order to make sure that
the migration still works in v9, and that we can rely on the
type checker for the best possible detection, we take advantage
of module augmentation and in-memory add the `Renderer` export
to the `@angular/core` module.

PR Close angular#33571
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…ular#33571)

The `renderer-to-renderer2` migration currently does not work
properly in v9 because the migration relies on the type checker
for detecting references to `Renderer` from `@angular/core`.

This is contradictory since the `Renderer` is no longer
exported in v9 `@angular/core`. In order to make sure that
the migration still works in v9, and that we can rely on the
type checker for the best possible detection, we take advantage
of module augmentation and in-memory add the `Renderer` export
to the `@angular/core` module.

PR Close angular#33571
@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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants