You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Andy-MS Note that | undefined has zero effect unless you're compiling with --strictNullChecks. There are undoubtedly many (many!) more places where we'd need to add these, so I'm not sure it makes a lot of sense to add only a few random ones.
@ahejlsberg That's a fair point, but I'm skeptical of whether we will be willing to make an all-at-once refactoring to operate in strictNullChecks. If we don't intend on ever migrating to strictNullChecks, then I'd tend to agree more, but incrementally annotating doesn't seem like a huge problem.
I acknowledge that it can be misleading to add these annotations for external users, but internally we are aware that we're not strictNullCheck-compliant.
My issue with these unchecked | undefined annotations is that they lure you into thinking that functions without the annotations will not accept or produce undefined values--which isn't the case. The fact is that until we switch to --strictNullChecks you can't tell from the annotations whether undefined is a permitted value or not, so I'd rather not pretend that you can.
I've been adding T | undefineds in some places just to help myself keep track of which functions do/don't return undefined. It's better than a comment and once we do move to SNC (which I hope is inevitable) it'll be less work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
5 participants
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.
No description provided.