-
Notifications
You must be signed in to change notification settings - Fork 12k
Angular 9+ incorrectly flags template variables as not existing in pug templates #18290
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
Comments
AFAICS the error occurs because incremental rebuilds run the type checker in a separate process, in which the custom Webpack rules are not applied. So the template file that gets loaded is really just the raw pug template itself, such that the
|
As @JoostK mentioned in the fork type checker we only accept raw HTML and SVG templates. What you can do to solve the issue is to disable fork type checking. |
Thanks for the replies, I know this isn't exactly a supported configuration so I appreciate it! Disabling the fork type checker did indeed resolve the issue. For anyone reading this that doesn't know how, I added
The downside now is that with my tiny one component demo application, the incremental rebuild jumped from around 225ms to 1250ms. Is there any reasonable way to add custom rules to the Webpack config the forked type checker uses? |
The forked type checker does not use Webpack so unfortunately there is no Webpack config to augment. |
Great! Glad to hear us difficult folk's nonsense will continue to work. I will probably stick with Angular 8 for now and keep an eye on that PR/v11. Thanks for the help and explanations! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes, had no issues in Angular 8. I'm guessing this has something to do with Ivy.
Description
TS component:
Pug template:
I have the above example component and template in an Angular project.
The project builds without issue using
ng build
andng-build --prod
The dev server starts without any issues using
ng serve
and the page renders as expected.Once I start making changes to the project and the dev server automatically rebuilds, it prints the following error:
Property 'item' does not exist on type 'TestComponent'. Did you mean 'items'?
The Angular application does appear to continue to work correctly and auto-rebuild on changes (printing that error every time),
but these false errors can potentially hide legitimate ones.
This happens with any variables generated with
*ngIf
or*ngFor
.div(*ngIf="name$ | async as name") {{name}}
: the{{name}}
portion will generate an errorThis issue occurs in both Angular 9 and 10.
I have tried two different methods of adding pug support to my project, the error occurs with both:
apply-loader
andpug-loader
)🔬 Minimal Reproduction
Here is a repository resulting from the below steps: https://github.com/entith/ng-cli-pug-template-variable-issue
ng new test --minimal --skip-tests --style sass --routing
cd test
npm i -D @angular-builders/custom-webpack pug pug-loader apply-loader
custom-webpack.config.js
file belowangular.json
as per the@angular-builders/custom-webpack
documentation to usecustom-webpack.config.js
ng g component test
ng serve
and wait for project to buildtest.component.pug
file: Compiled successfully
, and then a moment later the error should printitems
array in the component, the page should correctly reflect these changescustom-webpack.config.js
:🔥 Exception or Error
🌍 Your Environment
The text was updated successfully, but these errors were encountered: