tnicola / ngx-joyride

Angular Joyride/Tour library
https://tnicola.github.io/ngx-joyride/
MIT License
245 stars 98 forks source link

Getting error when compiling with ng build --aot #49

Open haegemonia76 opened 5 years ago

haegemonia76 commented 5 years ago

Describe the bug when i try to compile my angular 7, this error occured after the v2.2.4 excluded : ERROR in node_modules\ngx-joyride\joyride.d.ts.JoyrideStepComponent.html(1,47): : Object is possibly 'undefined'.

To Reproduce ng build "--aot"

Expected behavior no error when compiling my project.

Details (please complete the following information): List of the dependencies :

"dependencies": { "@angular/animations": "7.1.1", "@angular/cdk": "7.1.1", "@angular/common": "7.1.0", "@angular/compiler": "7.1.0", "@angular/core": "7.1.0", "@angular/forms": "7.1.0", "@angular/material": "7.1.1", "@angular/material-moment-adapter": "7.3.2", "@angular/platform-browser": "7.1.0", "@angular/platform-browser-dynamic": "7.1.0", "@angular/router": "7.1.0", "@fortawesome/fontawesome-free": "5.6.1", "@fullpage/angular-fullpage": "0.0.10", "@mat-datetimepicker/core": "2.0.1", "@mat-datetimepicker/moment": "2.0.1", "@netbasal/ngx-content-loader": "2.1.0", "@ngx-i18nsupport/tooling": "1.1.1", "@nomadreservations/ngx-stripe": "1.1.0", "@swimlane/ngx-charts": "10.0.0", "@tinymce/tinymce-angular": "3.0.0", "@types/socket.io-client": "1.4.32", "bootstrap": "4.1.3", "core-js": "2.5.4", "dragula": "3.7.2", "fullcalendar": "4.0.0-alpha", "fullcalendar-scheduler": "4.0.0-alpha.2", "hammerjs": "2.0.8", "highcharts": "7.0.3", "highcharts-angular": "2.4.0", "jquery": "3.3.1", "jquery-bracket": "0.11.1", "jwt-decode": "2.2.0", "konva": "2.5.1", "moment": "2.23.0", "msutils": "file:../msutils", "ng-fullcalendar": "1.7.1", "ng2-konva": "6.0.0", "ngx-captcha": "6.2.0", "ngx-clipboard": "11.1.9", "ngx-currency": "1.5.1", "ngx-moment": "3.3.0", "ngx-slick-carousel": "0.4.4", "ngx-socket-io": "2.1.1", "ngx-joyride": "2.2.9", "rxjs": "6.3.3", "slick-carousel": "1.8.1", "stripe-angular": "0.3.0", "tslib": "1.9.0", "typescript-tslint-plugin": "0.2.1", "zone.js": "0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "0.11.0", "@angular/cli": "7.1.1", "@angular/compiler-cli": "7.1.0", "@angular/language-service": "7.1.0", "@ngx-i18nsupport/ngx-i18nsupport": "1.1.0", "@types/angular": "1.6.51", "@types/jasmine": "3.3.1", "@types/jasminewd2": "2.0.6", "@types/jquery": "3.3.29", "@types/jwt-decode": "2.2.1", "@types/node": "8.9.4", "codelyzer": "4.5.0", "jasmine-core": "3.3.0", "jasmine-spec-reporter": "4.2.1", "karma": "3.1.1", "karma-chrome-launcher": "2.2.0", "karma-coverage-istanbul-reporter": "2.0.1", "karma-firefox-launcher": "1.1.0", "karma-jasmine": "2.0.1", "karma-jasmine-html-reporter": "1.4.0", "protractor": "5.4.0", "sass-lint": "1.12.1", "ts-node": "7.0.1", "tslint": "5.12.0", "tslint-eslint-rules": "5.4.0", "typescript": "3.1.1" }

tnicola commented 5 years ago

Hi @haegemonia76 , I'm sorry about that, I'll try to reproduce it and I'll be back with a reply soon.

tnicola commented 5 years ago

@haegemonia76 I'm not able to reproduce your error. Have you changed your tsconfig.json recently? Because it seems that ts compiler is doing a strict null check on the library and usually it shouldn't do that on third party libs. Can you post your tsconfig.json here please?

haegemonia76 commented 5 years ago

here's my tsconfig and tsconfig.app, but i didn't see anything wrong, there's no problem for the other package that i use. :/

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "strict": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "plugins": [
      {
        "name": "typescript-tslint-plugin",
        "alwaysShowRuleFailuresAsWarnings": false,
        "ignoreDefinitionFiles": true,
        "suppressWhileTypeErrorsPresent": false
      }
    ]
  }
}

tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": ["node"]
  },
  "exclude": ["test.ts", "**/*.spec.ts"]
}
tnicola commented 5 years ago

The strict: true is the one that is generating the error. Try to exclude the node_modules folder from your tsconfig:

"exclude": [
         ....
        "node_modules"
]

If that doesn't work try to set "strict": false. I'll improve the lib to be compatible with strict checks anyway.

haegemonia76 commented 5 years ago

Setting "strict" to false solved the problem thanks, but yeah, i prefer to let the strict mode to true. I hope that there will be a release soon 😄

DMZakaria commented 4 years ago

Hi, same issue here with aot, I have joyride v2.2.10 but there is no tag for this release

prafful-garg commented 4 years ago

i can not remove the strict mode from tsconfig, as this is the best practise that we are following. Is there any other way this problem can be solved?

abhigdrv commented 3 weeks ago

@ViewChild(JoyrideDirective) joyride: JoyrideDirective;

sub: Subscription;

ngAfterViewInit() { this.sub = this.joyride.done!.subscribe(_ => {}); }

ngOnDestroy() { this.sub.unsubscribe(); }