Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'optionToArray' helper #21628

Closed
wants to merge 1 commit into from
Closed

Add 'optionToArray' helper #21628

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 5, 2018

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

@rbuckton
Copy link
Member

rbuckton commented Feb 5, 2018

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

@ghost
Copy link
Author

ghost commented Feb 5, 2018

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