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

Enable non nullable types #193

Closed
remojansen opened this issue May 9, 2016 · 5 comments
Closed

Enable non nullable types #193

remojansen opened this issue May 9, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@remojansen
Copy link
Member

@remojansen remojansen commented May 9, 2016

We should upgrade to TypeScript 1.9 and use Non-nullable types.

Strict null checking can be enabled with a new --strictNullChecks compiler switch.

@remojansen remojansen added this to the 2.1.0-beta.1 milestone May 10, 2016
@remojansen remojansen modified the milestones: 2.0.0-rc.1, 2.1.0-beta.1 Jun 19, 2016
@remojansen remojansen modified the milestones: 2.1.0-beta.1, 2.0.0-rc.1 Jun 19, 2016
@remojansen
Copy link
Member Author

@remojansen remojansen commented Jun 19, 2016

I'be been doing some analysis on this and it is better to wait for now until TypeScript 2.0 becomes stable.

@remojansen remojansen modified the milestones: 3.0.0, 2.1.0 Jun 28, 2016
@remojansen remojansen modified the milestones: 5.0.0, 3.0.0 Aug 3, 2016
@remojansen remojansen modified the milestones: 4.0.0, 5.0.0 Sep 9, 2016
@goenning
Copy link
Contributor

@goenning goenning commented Sep 26, 2016

I'm starting to learn more about TypeScript and I think that InversifyJS is an awesome project to start on. I'd like to give this issue some love now that TS 2.0 is officially released.

I've started to play around and see what happens if we enable strictNullChecks on InversifyJS and I found interesting how this flag shows many potential problems within the code.

I'd like to see your thoughts about it.

I understand that many of these issues should be handled accordly. For example the Context class should not allow a null kernel to be used as it assumes everywhere inside the code that the context will always have non-falsy kernel.

Another example is the target/parentContext/parentRequest properties of the Request class. All of them can be null by definition, but mostly everywhere the code does not expect it be. While we don't run in any issue during run-time, the TS 2.0 compiler is always complaining about it. Sure we can just throw out some not-nul operators (request.target!.name!), but I don't think it's the best way of dealing with nullables. I'm a big fan of the Null Object Pattern btw, maybe there is some room for it here.

Anyway, I'll just fork it and try to play around with this and see where I can get. Just wanted to know if this is something you're already working on, or maybe you got some outcome that you could share from your previous analysis.

By the way, what you think about moving from null to undefined?
https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#null-and-undefined
https://medium.com/@basarat/null-vs-undefined-in-typescript-land-dc0c7a5f240a#.s3e4ea8z1

@remojansen
Copy link
Member Author

@remojansen remojansen commented Sep 26, 2016

Hi @goenning thanks for the comments. I tried this sometime ago and it is a big change. Some help is more than welcome. I will take a look to your branch over the next few days and share my thoughts.

I'm working at the moment on a big refactor you can explore it here and see the changes here. I would recommend you to wait until I get it merged it into master or it will be a nightmare to resolve the conflicts. I'm planning to get it done over the next 2-3 weeks.

Also one of the things that we need to explore is that the changes should improve the code (prevent issues) but it should not cause trouble for our users, please keep in mind that 😄

@goenning
Copy link
Contributor

@goenning goenning commented Sep 26, 2016

Oh, that's good to know. I prefer to wait and avoid a big merge conflict. I'll keep an eye on it :)

@remojansen
Copy link
Member Author

@remojansen remojansen commented Oct 21, 2016

Hi @goenning I just merged the big refactor that I was talking about 😉

@remojansen remojansen modified the milestones: 3.0.0, 4.0.0 Nov 29, 2016
@remojansen remojansen self-assigned this Dec 2, 2016
@remojansen remojansen mentioned this issue Dec 2, 2016
5 of 9 tasks complete
remojansen added a commit that referenced this issue Dec 2, 2016
* Remove default exports

* Upgraded tslint

* Implemented #408

* Implementes #419

* fixes #405

* release 3.0.0-beta.2

* Implements #421 & refactor enum -> literal types

* Added #421 docs

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193
@remojansen remojansen closed this Dec 2, 2016
remojansen added a commit that referenced this issue Dec 4, 2016
* Remove default exports

* Upgraded tslint

* Implemented #408

* Implementes #419

* fixes #405

* release 3.0.0-beta.2

* Implements #421 & refactor enum -> literal types

* Added #421 docs

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* Working on #193

* [WIP] #418

* [WIP] #418
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.