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

Declaring a pipe in two modules does not produce a diagnostic [Importing pipes in sub modules does not compile] #33586

Closed
neofuture opened this issue Nov 4, 2019 · 8 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq3: high type: bug/fix
Milestone

Comments

@neofuture
Copy link

neofuture commented Nov 4, 2019

Included working custom pipe, modules is in /modules/contact-manager for reference

import { NgModule } from '@angular/core';
import {CommonModule} from '@angular/common';
import { MainComponent } from './main.component';
import {JsonPipe} from '../../pipes/json.pipe';


@NgModule({
  declarations: [MainComponent, JsonPipe],
  imports: [
    CommonModule
  ]
})
export class ContactManagerModule { }

use pipe in component template with {{ objectItem | json }}

get following error

ERROR in Error: Missing pipe: json at Context.getPipeByName (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:650:23) at TcbExpressionTranslator.resolve (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:1114:37) at AstTranslator.maybeResolve (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:1078:84) at AstTranslator.translate (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/expression.js:69:33) at /Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/expression.js:117:124 at Array.reduce (<anonymous>) at AstTranslator.visitInterpolation (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/expression.js:117:36) at Interpolation.visit (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler/bundles/compiler.umd.js:6481:28) at AstTranslator.translate (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/expression.js:73:24) at Object.astToTypescript (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/expression.js:49:27) at TcbExpressionTranslator.translate (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:1078:33) at tcbExpression (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:1065:27) at TcbTextInterpolationOp.execute (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:288:24) at Scope.executeOp (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:866:26) at Scope.render (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:805:22) at Object.generateTypeCheckBlock (/Users/carlfearby/Dropbox/Angular Projects/Framework/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:44:37)

pipe works fine in appModule level

env

Package Version

@angular-devkit/architect 0.900.0-next.16
@angular-devkit/build-angular 0.900.0-next.16
@angular-devkit/build-optimizer 0.900.0-next.16
@angular-devkit/build-webpack 0.900.0-next.16
@angular-devkit/core 9.0.0-next.16
@angular-devkit/schematics 9.0.0-next.16
@angular/cdk 8.2.3
@angular/cli 9.0.0-next.16
@ngtools/webpack 9.0.0-next.16
@schematics/angular 9.0.0-next.16
@schematics/update 0.900.0-next.16
rxjs 6.5.3
typescript 3.6.4
webpack 4.41.2

@neofuture
Copy link
Author

For information I had the same issue when trying to use PrimeNG I got a similar error to do with pipes

@neofuture
Copy link
Author

Just incase its relevant

im Lazy loading the module components with

      const {MainComponent} = await import('../../modules/contact-manager/main.component');
      const componentRef = this.viewContainer.createComponent(this.cfr.resolveComponentFactory(MainComponent));
      componentRef.instance.windowItem = this.windowItem;

@AndrewKushnir AndrewKushnir added the area: compiler Issues related to `ngc`, Angular's template compiler label Nov 5, 2019
@ngbot ngbot bot added this to the needsTriage milestone Nov 5, 2019
@JoostK JoostK added the needs reproduction This issue needs a reproduction in order for the team to investigate further label Nov 5, 2019
@JoostK
Copy link
Member

JoostK commented Nov 5, 2019

The error itself has been improved in #33454 to generate a diagnostic instead, which at least should resolve the stacktrace (but still cause the compilation to fail. This will be released per rc.1.

Regarding PrimeNG, it's not currently working, please follow #30565 for updates.

The issue you're posting is unclear to me, in a sense that there's no known bugs around this area for the example you shared. I can imagine this is in combination with some library, in which case ngcc may be processing something incorrectly. Could you please share a repro, preferably through a Github repository? Thanks!

@neofuture
Copy link
Author

Here is a repo with the pipe intentionally not working

https://github.com/neofuture/broken-pipe

@JoostK JoostK removed the needs reproduction This issue needs a reproduction in order for the team to investigate further label Nov 5, 2019
@alxhub
Copy link
Member

alxhub commented Nov 5, 2019

The issue here is that JsonPipe is declared in two NgModules: AppModule and ContactManagerModule. This should be an error in the compiler in Ivy, but isn't.

I've updated the title of this issue to reflect that and track this bug.

@ngbot ngbot bot modified the milestones: needsTriage, Backlog Nov 5, 2019
@alxhub alxhub changed the title Importing pipes in sub modules does not compile Declaring a pipe in two modules does not produce a diagnostic [Importing pipes in sub modules does not compile] Nov 5, 2019
@neofuture
Copy link
Author

OK cool is there a work around but if I don't include It in the sub module I get an error

@alxhub
Copy link
Member

alxhub commented Jan 28, 2020

This was fixed in #34404!

@alxhub alxhub closed this as completed Jan 28, 2020
@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 Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq3: high type: bug/fix
Projects
None yet
Development

No branches or pull requests

4 participants