Skip to content

Add some missing | undefined in parser.ts#17407

Merged
2 commits merged into
masterfrom
parser_undefined
Jul 27, 2017
Merged

Add some missing | undefined in parser.ts#17407
2 commits merged into
masterfrom
parser_undefined

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Jul 25, 2017

No description provided.

@ghost ghost requested a review from sandersn July 25, 2017 18:13
@ahejlsberg
Copy link
Copy Markdown
Member

@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.

@DanielRosenwasser
Copy link
Copy Markdown
Member

@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.

@ahejlsberg
Copy link
Copy Markdown
Member

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.

@RyanCavanaugh
Copy link
Copy Markdown
Member

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.

@ghost ghost merged commit 70e5c6b into master Jul 27, 2017
@ghost ghost deleted the parser_undefined branch July 27, 2017 18:25
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
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.

5 participants