Skip to content

Add 'optionToArray' helper - #21628

Closed
Deleted user (ghost) wants to merge 1 commit into
masterfrom
optionToArray
Closed

Deleted user (ghost) wants to merge 1 commit into
masterfrom
optionToArray

Conversation

@ghost

Copy link
Copy Markdown

Adds a helper function for converting T | undefined to T[].

@rbuckton

Copy link
Copy Markdown
Contributor

Is this really necessary? It will be inlined to the same code and its not much shorter than writing x ? [x] : [].

@ghost

Copy link
Copy Markdown
Author

Perhaps not, though in the linked PR I want to write optionToArray(getActionsForAddMissingInitializer(context, propertyDeclaration, newLineCharacter)) instead of applying to a local variable -- would be nice to be able to write let x = getActions... in x ? [x] : [], but we could do it in reverse with a lambda (x => x ? [x] : [])(...) (in other words, write the definition of optionToArray inline).

@ghost ghost closed this Feb 5, 2018
@ghost
ghost deleted the optionToArray branch February 5, 2018 19:30
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jul 3, 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.

1 participant