Ng-bootstrap: Strict null checks with datepicker NgbDateStruct

Created on 8 May 2017  路  3Comments  路  Source: ng-bootstrap/ng-bootstrap

Please remember, the issues forum is __NOT__ for support requests. It is for bugs and feature requests only.
Please read https://github.com/ng-bootstrap/ng-bootstrap/blob/master/CONTRIBUTING.md and search
existing issues (both open and closed) prior to opening any new issue and ensure you follow the instructions therein.

Bug description:

Uncompatible with typescript strict null checks Support. The parse method should return null or NgbDateStruct. Right now return only NgbDateStruct.

Link to minimally-working plunker that reproduces the issue:

You can fork a plunker from one of our demos and use it as a starting point.
Please note that we can _not_ act on bug reports without a minimal reproduction scenario in plunker. Here is why:
https://github.com/ng-bootstrap/ng-bootstrap#you-think-youve-found-a-bug

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 4

ng-bootstrap:

Bootstrap:

feature

Most helpful comment

Yeh, we should review this project for the proper strict null checks...

All 3 comments

For someone who has this issue but want to use strict null checks the workaround is to add any before null

    if (!value) {
        return <any>null;
    }
    return d.isValid() ? { year: d.year(),
            month: d.month() + 1,
            day: d.date() } : <any>null;

Not beautiful but works :-)

Yeh, we should review this project for the proper strict null checks...

So I took a stab at trying to implement proper strict null checks...this is not an easy task. This pollutes a lot of areas, and needs a lot of love.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elainebyrne picture elainebyrne  路  3Comments

tmeneau picture tmeneau  路  3Comments

BotanMan picture BotanMan  路  3Comments

raysunqi picture raysunqi  路  3Comments

CarlosTorrecillas picture CarlosTorrecillas  路  3Comments