Support an array of names
See original GitHub issueCould we have support for an array of values that returns an array.
e.g.
myProperties: string[] = nameof<Company>(o => o.Name, o => o.Address1, o => o.Address2);
transpiles to:
myProperties = ["Name", "Address1", "Address2"];
Maybe even call it namesOf?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Name an array constant - Microsoft Support
To name an array constant, click Formula, then Define Name. Enter a name and the constant, then you can use the constant as...
Read more >How to pass an array within a query string? - Stack Overflow
I want that query string value to be treated as an array- I don't want the array to be exploded so that it...
Read more >Array - JavaScript - MDN Web Docs
The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name ......
Read more >Work with arrays | BigQuery - Google Cloud
With Google Standard SQL, you can construct array literals, build arrays from subqueries using the ARRAY function, and aggregate values into an array...
Read more >JavaScript Arrays - W3Schools
Many programming languages support arrays with named indexes. Arrays with named indexes are called associative arrays (or hashes). JavaScript does not support ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is merged and available now thanks to @cecilyth!
One important thing to note is that the following transform is not yet available…
… we’ll have to wait for TypeScript to support calling functions with a variable number of type arguments (ex.
nameof.toArray<...T>(): string[]
). A workaround would be to just add a bunch of function declarations with different number of type arguments (ex.nameof.toArray<T1>(): string[]; nameof.toArray<T1, T2>(): string[]; ...etc...
). Might be worth it to do that actually.Perhaps it would also be good to implement something like
nameof.toArray<T1, T2>((o1, o2) => [o1.test, o2.asdf]);
and with more type parameters.Anyway, something to think about for improving this. Please let me know if you would like any of these features.
Interesting idea. Perhaps the following?
Signatures: