GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Destructuring assignment removes undefined from type when default value is given by sandersn · Pull Request #9422 · microsoft/TypeScript

Conversation

@sandersn

@sandersn Nathan Shively-Sanders (sandersn) commented Jun 29, 2016

Copy link
Copy Markdown
Member

Fixes #9341

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sandersn
Destructuring assignment removes undefined from type when default val…
c5e680c
…ue is given
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Jun 29, 2016
@sandersn

Nathan Shively-Sanders (sandersn) commented Jun 29, 2016

Copy link
Copy Markdown
Member Author

Mohamed Hegazy (@mhegazy) I think you are the best person to look at this while Anders Hejlsberg (@ahejlsberg) is gone.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Jun 29, 2016

Copy link
Copy Markdown
Contributor

Looks good to me. i would give Anders Hejlsberg (@ahejlsberg) some more time to check it as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sandersn

Nathan Shively-Sanders (sandersn) commented Jun 29, 2016

Copy link
Copy Markdown
Member Author

Sure. Anders Hejlsberg (@ahejlsberg) do you want to take a look?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ahejlsberg
ahejlsberg reviewed Jun 30, 2016
View reviewed changes
Comment thread src/compiler/checker.ts Outdated
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
// undefined from the final type.
if (strictNullChecks &&
!(getCombinedTypeFlags(checkExpressionCached(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) {

@ahejlsberg Anders Hejlsberg (ahejlsberg) Jun 30, 2016

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Use checkExpression here, not checkExpressionCached. The latter should only be used (a) when you know that contextual types will never have an effect on the expression and (b) when other checks of the same expression also use the caching version. Neither are true here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sandersn Nathan Shively-Sanders (sandersn) Jun 30, 2016

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Jun 30, 2016

Copy link
Copy Markdown
Member

👍 Once you make the indicated change.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sandersn
Use checkExpression, not checkExpressionCached
5f6e25c
@mhegazy
Mohamed Hegazy (mhegazy) merged commit 07d7ec3 into master Jun 30, 2016
@mhegazy
Mohamed Hegazy (mhegazy) deleted the allow-destructuring-assignment-with-default-of-undefined-optional-property branch June 30, 2016 19:41
@microsoft 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.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@sandersn @mhegazy @ahejlsberg @msftclas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.