components icon indicating copy to clipboard operation
components copied to clipboard

ERROR in Assertion error: failed to find directive with exportAs: matTooltip

Open zwjohn opened this issue 7 years ago • 4 comments

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue

Steps to reproduce:

  1. Create a new project using Angular CLI 8.3.3

  2. Open tsconfig.app.json and set ivy to true
    "angularCompilerOptions": { "enableIvy": true }

  3. Add <mat-icon #tooltip="matTooltip" matTooltip="123" matTooltipPosition="right"> info_outline to app.component.html

  4. Import MatTooltipModule, MatIconModule, FileUploadModule in app.module.ts

  5. run "ng build --aot"

  6. you will see ERROR in Assertion error: failed to find directive with exportAs: matTooltip error

Expected Behavior

What behavior were you expecting to see?

No error

Actual Behavior

What behavior did you actually see?

ERROR in Error: Assertion error: failed to find directive with exportAs: matTooltip at C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:28628:31 at Array.forEach () at DirectiveBinder.visitElementOrTemplate (C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:28611:29) at DirectiveBinder.visitElement (C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:28585:76) at Element.visit (C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:4160:71) at C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:28583:60 at Array.forEach () at DirectiveBinder.ingest (C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:28583:22) at Function.DirectiveBinder.apply (C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:28578:21) at R3TargetBinder.bind (C:\ng-test\project825\node_modules@angular\compiler\bundles\compiler.umd.js:28425:38) at ComponentDecoratorHandler.typeCheck (C:\ng-test\project825\node_modules@angular\compiler-cli\src\ngtsc\annotations\src\component.js:373:64) at C:\ng-test\project825\node_modules@angular\compiler-cli\src\ngtsc\transform\src\compilation.js:354:43 at Map.forEach () at IvyCompilation.typeCheck (C:\ng-test\project825\node_modules@angular\compiler-cli\src\ngtsc\transform\src\compilation.js:347:29) at NgtscProgram.getTemplateDiagnostics (C:\ng-test\project825\node_modules@angular\compiler-cli\src\ngtsc\program.js:371:25) at NgtscProgram.getNgSemanticDiagnostics (C:\ng-test\project825\node_modules@angular\compiler-cli\src\ngtsc\program.js:168:78)

Environment

  • Angular:
  • CDK/Material:
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):

Windows 10 Node version v12.4.0 NPM version 6.9

This is my package.json

{ "name": "project825", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "9.0.0-next.6", "@angular/common": "9.0.0-next.6", "@angular/compiler": "9.0.0-next.6", "@angular/core": "9.0.0-next.6", "@angular/forms": "9.0.0-next.6", "@angular/platform-browser": "9.0.0-next.6", "@angular/platform-browser-dynamic": "9.0.0-next.6", "@angular/router": "9.0.0-next.6", "@angular/material": "^8.2.0", "@angular/cdk": "^8.2.0", "ng2-file-upload": "^1.3.0", "rxjs": "^6.5.3", "tslib": "^1.10.0", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "~0.803.3", "@angular/cli": "9.0.0-next.4", "@angular/compiler-cli": "9.0.0-next.6", "@angular/language-service": "9.0.0-next.6", "@types/jasmine": "~3.3.13", "@types/node": "~12.7.5", "codelyzer": "^5.0.1", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "^2.0.5", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.2", "protractor": "^5.4.2", "ts-node": "~8.3.0", "tslint": "~5.20.0", "typescript": "3.5.3" } }

zwjohn avatar Sep 16 '19 13:09 zwjohn

Judging based on the code provided in step 3, it seems like you haven't set the matTooltip attribute.

crisbeto avatar Sep 16 '19 15:09 crisbeto

Judging based on the code provided in step 3, it seems like you haven't set the matTooltip attribute.

@crisbeto you are right, I didn't paste the full code, I've update the my report above.

I've been playing around, it seems importing ng2-file-upload library (FileUploadModule) to app.module caused this, this was not an issue when ivy is disabled.

I can't figure out why ng2-file-upload caused ivy compilation issue for material.

zwjohn avatar Sep 16 '19 19:09 zwjohn

It seems ng2-file-upload is not compatible with ivy, causing material to throw errors. The error is very misleading, it didn't mention the library in question at all. I spent a whole day to test library by library to see which one causes the issue. I guess that is ivy team's issue. Therefore closing this issue. Thanks

zwjohn avatar Sep 16 '19 19:09 zwjohn

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.