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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty binding attribute in template gives EmptyExpr compiler error #30076

Closed
jponeill opened this issue Apr 24, 2019 · 1 comment 路 May be fixed by #30938

Comments

@jponeill
Copy link

commented Apr 24, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/compiler-cli/ngtsc

Is this a regression?

Description

Compiling an IVY project that has an empty binding attribute in a component template gives the following error:

ERROR in : Error: Unknown node type: function EmptyExpr() {
return _super !== null && _super.apply(this, arguments) || this;
}

馃敩 Minimal Reproduction

Add an empty [myBindingAttrib] to any element in template and you get the compiler error in the trace below.

For example, adding the following to a component template:

<div [innerHTML]> </div>

and executing:

ng build --configuration production

... gives the error in the trace below

馃敟 Exception or Error



ERROR in : Error: Unknown node type: function EmptyExpr() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
    at astToTypescript (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/expression.js:142:19)
    at Object.astToTypescript (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/expression.js:54:20)
    at tcbExpression (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:755:29)
    at TcbUnclaimedInputsOp.execute (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:339:32)
    at Scope.executeOp (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:622:26)
    at Scope.render (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:561:22)
    at Object.generateTypeCheckBlock (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:43:37)
    at TypeCheckFile.addTypeCheckBlock (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_file.js:47:41)
    at TypeCheckContext.addTemplate (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/context.js:98:36)
    at ComponentDecoratorHandler.typeCheck (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/component.js:311:21)
    at /Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:328:43
    at Map.forEach ()
    at IvyCompilation.typeCheck (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:321:29)
    at NgtscProgram.getTemplateDiagnostics (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/program.js:362:25)
    at NgtscProgram.getNgSemanticDiagnostics (/Users/jimoneill/WebstormProjects/x/node_modules/@angular/compiler-cli/src/ngtsc/program.js:164:78)
    at checkDiagnostics (/Users/jimoneill/WebstormProjects/x/node_modules/@ngtools/webpack/src/gather_diagnostics.js:38:27)

馃實 Your Environment

Angular Version:



Angular CLI: 8.0.0-beta.17
Node: 10.12.0
OS: darwin x64
Angular: 8.0.0-beta.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0-beta.17
@angular-devkit/build-angular     0.800.0-beta.17
@angular-devkit/build-optimizer   0.800.0-beta.17
@angular-devkit/build-webpack     0.800.0-beta.17
@angular-devkit/core              8.0.0-beta.17
@angular-devkit/schematics        8.0.0-beta.17
@angular/cli                      8.0.0-beta.17
@angular/events                   
@ngtools/webpack                  8.0.0-beta.17
@schematics/angular               8.0.0-beta.17
@schematics/update                0.800.0-beta.17
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0
  

Anything else relevant?
Maybe handle like PR #30024 (w/ a warning?)? Or give a an error with more detail.

@yonexbat

This comment has been minimized.

Copy link

commented Jun 9, 2019

How do I know which template file generates this error? Would be nice if it is printed along the exception.

JoostK added a commit to JoostK/angular that referenced this issue Jun 9, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076, angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Jun 9, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076, angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Jun 9, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076, angular#30929

@JoostK JoostK added the state: has PR label Jun 9, 2019

JoostK added a commit to JoostK/angular that referenced this issue Jun 9, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076, angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Jun 10, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Jun 22, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Jul 15, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Jul 15, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Jul 16, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929
JoostK added a commit to JoostK/angular that referenced this issue Aug 20, 2019
fix(ivy): handle empty bindings in template type checker
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929
ngdevelop-tech added a commit to ngdevelop-tech/angular that referenced this issue Aug 27, 2019
fix(ivy): handle empty bindings in template type checker (angular#31594)
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929

PR Close angular#31594
sabeersulaiman added a commit to sabeersulaiman/angular that referenced this issue Sep 6, 2019
fix(ivy): handle empty bindings in template type checker (angular#31594)
When a template contains a binding without a value, the template parser
creates an `EmptyExpr` node. This would previously be translated into
an `undefined` value, which would cause a crash downstream as `undefined`
is not included in the allowed type, so it was not handled properly.

This commit prevents the crash by returning an actual expression for empty
bindings.

Fixes angular#30076
Fixes angular#30929

PR Close angular#31594
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.