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

Alert component: AOT compile with strictNullChecks fails #14056

Closed
peterkelly opened this issue Feb 21, 2018 · 2 comments
Closed

Alert component: AOT compile with strictNullChecks fails #14056

peterkelly opened this issue Feb 21, 2018 · 2 comments
Labels
ionitron: v3 moves the issue to the ionic-v3 repository

Comments

@peterkelly
Copy link

Ionic version: (check one with "x")
[ ] 2.x
[x] 3.x
[ ] 4.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request

Current behavior:

When compiling an application that uses ionic-angular, and strictNullChecks is enabled in tsconfig.json, AOT compilation of the Alert component template fails with the following error:

Error at /Users/peter/myapp/node_modules/ionic-angular/components/alert/alert-component.d.ts.AlertCmp.html(1,417): Object is possibly 'undefined'.
Error at /Users/peter/myapp/node_modules/ionic-angular/components/alert/alert-component.d.ts.AlertCmp.html(1,1760): Object is possibly 'undefined'.

Expected behavior:

The app should compile with no errors.

Note: I understand that building Ionic itself is not yet supported with strictNullChecks enabled, but this bug is the only one that I'm aware of which prevents applications themselves from being built using Ionic and strictNullChecks.

Steps to reproduce:

  1. ionic start myapp blank
  2. cd myapp
  3. Edit tsconfig.json and add "strictNullChecks": true, inside compilerOptions
  4. node_modules/.bin/ngc

Other information:

The compile errors come from two places in the template within src/components/alert/alert-component.ts where possibly-undefined properties of the component are accessed: d.inputs and d.buttons.

I have prepared a patch (which we have been using in our app for several months) and will submit a pull request.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

ionic info

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

local packages:

    @ionic/app-scripts : 3.1.8
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.9.4
    npm  : 5.5.1 
    OS   : macOS High Sierra

Misc:

    backend : legacy
@ionitron-bot ionitron-bot bot added the triage label Feb 21, 2018
peterkelly added a commit to Keyoniq/ionic that referenced this issue Feb 21, 2018
Modify the Alert component's template to add extra checks to d.inputs
and d.buttons to avoid compile errors when using ahead-of-time
compilation when strictNullChecks is enabled in tsconfig.json.

Fixes: ionic-team#14056
@paulstelzer paulstelzer added the ionitron: v3 moves the issue to the ionic-v3 repository label Dec 3, 2018
@ionitron-bot
Copy link

ionitron-bot bot commented Dec 3, 2018

Thanks for the issue! We have moved the source code and issues for Ionic 3 into a separate repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.

Thank you for using Ionic!

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 3, 2018

Issue moved to: ionic-team/ionic-v3#763

@ionitron-bot ionitron-bot bot closed this as completed Dec 3, 2018
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 3, 2018
@ionitron-bot ionitron-bot bot removed the triage label Dec 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ionitron: v3 moves the issue to the ionic-v3 repository
Projects
None yet
Development

No branches or pull requests

2 participants