question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

@angular/core update schematic v9 to v10 adds odd todo comments in a correct-looking file

See original GitHub issue

๐Ÿž bug report

Affected Package

The issue is caused by package @angular/core

Description

ng update @angular/core from v9 to v10 adds multiple comments that tell me I need to change something which I did not expect

> Undecorated classes with Angular features migration.
  In version 10, classes that use Angular features and do not have an Angular decorator are no longer supported.
  Read more about this here: https://v10.angular.io/guide/migration-undecorated-classes
    Could not migrate all undecorated classes that use Angular features.
    Please manually fix the following failures:
    โฎ‘   projects\client-core\src\lib\i18n\model-i18n\translateField.pipe.ts@6:1: Class uses Angular features but cannot be migrated automatically. Please add an appropriate Angular decorator.

The code looks like this

import { AccessPathLike } from '@aeb/graphql-accessor';
import { ChangeDetectorRef, OnDestroy, Pipe, PipeTransform } from '@angular/core';
import { Subscription } from 'rxjs';
import { ModelLocalizationService } from './model-localization.service';

// TODO: Add Angular decorator.
// TODO: Add Angular decorator.
// TODO: Add Angular decorator.
// TODO: Add Angular decorator.
// TODO: Add Angular decorator.
// TODO: Add Angular decorator.
@Pipe({
    name: 'translateField',
    pure: false
})
export class TranslateFieldPipe implements PipeTransform, OnDestroy {
    private subscription: Subscription | undefined = undefined;
    // don't initialize with undefined because then the pipe might break consumers expecting string
    private currentValue: string = '';
    private currentPath: AccessPathLike | undefined = undefined;

    constructor(
        private readonly modelLocalizationService: ModelLocalizationService,
        private readonly changeDetectorRef: ChangeDetectorRef
    ) {
    }

    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
            this.subscription = undefined;
        }
    }

    transform(value: AccessPathLike|undefined): string {
        if (value === this.currentPath) {
            return this.currentValue;
        }
        this.currentPath = value;
        if (this.subscription) {
            this.subscription.unsubscribe();
            this.subscription = undefined;
        }
        if (!value) {
            return '';
        }
        this.subscription = this.modelLocalizationService.watchFieldLabel(value).subscribe(label => this.updateValue(label));
        return this.currentValue;
    }

    private updateValue(value: string) {
        this.currentValue = value;
        this.changeDetectorRef.markForCheck();
    }
}

It already has a decorator. I assume this is a bug and I canโ€™t do anything to satisfy ng update @angular/core ?

๐Ÿ”ฌ Minimal Reproduction

Iโ€™m not sure if the above example alone is enough for a reproduction on your side. Let me know if you need more!

๐ŸŒ Your Environment

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / โ–ณ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.0.0
Node: 10.19.0
OS: win32 x64

Angular: 10.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: No

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.900.7
@angular-devkit/build-angular      0.1000.0
@angular-devkit/build-ng-packagr   0.1000.0
@angular-devkit/build-optimizer    0.1000.0
@angular-devkit/build-webpack      0.1000.0
@angular-devkit/core               10.0.0
@angular-devkit/schematics         10.0.0
@angular/flex-layout               10.0.0-beta.32
@ngtools/webpack                   10.0.0
@schematics/angular                10.0.0
@schematics/update                 0.1000.0
ng-packagr                         10.0.0
rxjs                               6.5.4
typescript                         3.9.5
webpack                            4.43.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
leoncommented, Jun 25, 2020

Also noted that angular adds the same error to services that implement OnDestroy

// TODO: Add Angular decorator.
@Injectable()
export class MyService implements OnDestroy {
}
0reactions
angular-automatic-lock-bot[bot]commented, Jul 26, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TODO comments | WebStorm Documentation - JetBrains
In WebStorm, you can add special types of comments that are highlighted in the editor and listed in the TODO tool window.
Read more >
How to insert TODO comment in React JSX file - Stack Overflow
It's a bit weird (you'll see for yourself), but it highlights as a TODO, throws no errors and is picked up by TODO...
Read more >
Todo Tree - Visual Studio Marketplace
Extension for Visual Studio Code - Show TODO, FIXME, etc. comment tags in a tree view.
Read more >
Do TODO comments make sense? [closed]
It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with factsย ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found