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.

Inputs are not inherited when Ivy is enabled

See original GitHub issue

🐞 bug report

Is this a regression?

No

Description

We build our app with ngc and closure compiler. After enabling Ivy ngc fails almost immediately. Could not find any instructions for this case.

🔬 Minimal Reproduction

        import {platformBrowser} from '@angular/platform-browser';
        import {AppModuleNgFactory} from './application.module.ngfactory';

        platformBrowser()
            .bootstrapModuleFactory(AppModuleNgFactory)
            .catch(e => console.error('Application bootstrap failed', e));

🔥 Exception or Error


[11:51:23] Spa_Source/main.aot.ts:7:34 - error TS2307: Cannot find module './application.module.ngfactory'.

7 import {AppModuleNgFactory} from './application.module.ngfactory';

🌍 Your Environment

Angular Version:


8.0.0-beta.14

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:68 (32 by maintainers)

github_iconTop GitHub Comments

4reactions
fr0commented, Aug 8, 2019

@fxck It’s not working because FormBase does not have an Angular decorator like @Component or @Directive of its own, only an @Input decorator. Currently in Ivy, a class like FormBase is treated specially as something known as a base def. Such definitions are not taken into account in the template type checker, hence it doesn’t work.

Going forward, the notion of such base defs will disappear, and an @Directive decorator becomes required for any class that has Angular behavior such as @Inputs. This is currently a work-in-progress effort, with #31379 being a prerequisite for this approach to become viable.

I am confused because this works just fine when Ivy is disabled? So should we technically be adding @Directive to our component base classes even when not using Ivy?

Doing so is a bit awkward, because then that causes two more issues:

  1. Angular language service gives error “BaseClass is not declared in any Angular module” (well, duh, but this is intended)
  2. I have to create a selector for a thing that’s never going to be directly instantiated. Not the end of the world, but weird.

Please bear with us while this is being worked on.

Completely understood. However, I am very slightly nervous because there is already a prerelease for 9.0.0 and issues like this convince me that Ivy is still a ways from being ready.

3reactions
karacommented, Oct 8, 2019

In this case I may expect Bar to simply share the selector of Foo, without knowing what it is. But an empty @Directive() would make that not possible anymore, isn’t it?

@trotyl In that case, you would have to copy over the decorator (that’s what the schematic does for you automatically). It is slightly more boilerplate, but it’s more explicit, so it’s easier for anyone to look at the directive and figure out what its selector is without having to drill down the inheritance tree. You do have to know what the selector is, though. It could be an argument for another feature down the line, but probably not for v9.

In any case, thanks for pointing out the ambiguity. Seems like we need to add another FAQ to the guide about this. cc @kapunahelewong

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 9 with Ivy, problem when calling a function like this ...
The "unique" part is working by the way, and when I deactivate Ivy compiler (tscongif.app.json / angularCompilerOptions / enableIvy: false), ...
Read more >
Component features with Angular Ivy - DEV Community ‍ ‍
In the first release version of Ivy, component features are not publically available. ... Component mixins without inheritance or decorators.
Read more >
Inherited component or directive properties not recognized ...
With IVY disabled it works fine because packages are not pre-compiled. So as a temporary solution I would suggest to disable IVY until...
Read more >
Ivy compatibility guide - Angular
If you're seeing errors, first temporarily turn off Ivy in your tsconfig.json and re-start your app. If you're still seeing the errors, they...
Read more >
Understand Composition and inheritance in Angular.
But the problem comes when we feel the over-dependencies in the constructor to the base class, or send values to something not related...
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