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.

AoT: inheritance error not reported correctly

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior If a component extends a class with implemented lifecycle hooks, they’re not being called when building with aot (both in prod and dev). It’s alright though when running ng build --prod --aot=false

Expected behavior Lifecycle hooks inheritance should be working

Minimal reproduction of the problem with instructions

import { Component, OnInit } from '@angular/core';

class Foo implements OnInit {
    ngOnInit() {
        alert('Foo initialized');
    }
}

@Component({
    selector: 'app-root',
    template: 'App works',
})
export class AppComponent extends Foo {}

What is the motivation / use case for changing the behavior?

Please tell us about your environment: Windows 10

  • Angular version: 4.0.3
  • Browser: any

  • Language: TypeScript 2.3.0

  • Node (for AoT issues): node --version = 7.8.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chuckjazcommented, May 1, 2017

The is an error condition that is not being reported ngc nor by TypeScript as, by default, the "declaration" option is false.

An exported class must only extend exported classes. To have TypeScript report this case, change the "declaration" option to true in your tsconfig.json file.

To fix this in your code, add export in front of the declaration of Foo.

I am keeping this open as a bug because we should report this as an error in ngc even if TypeScript allows it.

REPO:

  1. git clone https://github.com/chuckjaz/e16335.git
  2. cd e16335
  3. yarn
  4. ng build --aot

Expected: Error report that Foo is not exported. Received: Compiled successfully but produced incorrect code (“App works: not initialized” instead of “App works: initialized”).

0reactions
angular-automatic-lock-bot[bot]commented, Sep 12, 2019

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

Angular compiler options
When true , the compiler does not look at the TypeScript version and does not report an error when an unsupported version of...
Read more >
Avoid compile-time static initialization of classes when using ...
I'm working on a project using Clojure and RoboVM. We use AOT compilation to compile Clojure to JVM classes, and then use RoboVM...
Read more >
Attack on Titan's Final Chapter Has DESTROYED A Masterpiece
Attack on Titan's Ending was a Fumbling instead of Rumbling. Attack on Titan Final Chapter 139 has been extremely controversial with the ...
Read more >
List of Error and Warning Messages - Microsoft Learn
Checks that the class name stated in the attribute of an upgrade script exists in the AOT. BPErrorClassNameNotFound, @SYS309404. Method %1 in ...
Read more >
The pipe 'async' could not be found - Stack Overflow
@NgModule.declarations aren't inherited by child modules. If you need pipes, directives, components from a module, the module should be ...
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