Skip to content

Conversation

@mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Feb 7, 2017

  • Change the order of the overloads to make the null last. this allows the error to show even in non-strict null checks mode
  • Add an overload for union object | null to address Object.create({} | null) #13932, and make sure the result is the union of the input, e.g. Object.create(T | null) is T | object.

//CC @RyanCavanaugh and @DanielRosenwasser

Fixes #13932


declare var union: null | { a: number, b: string };

var n = Object.create(null); // object

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a 'well defined' object, namely {}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in an input {} is not the same as object. object is more specific than {}. in here it does not matter. i used object to avoid having a type of {} | object.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thank you. (:

@mhegazy mhegazy merged commit ae02db4 into master Feb 14, 2017
@mhegazy mhegazy deleted the FixObjectCreate branch February 14, 2017 21:29
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants