alternative to nesting quotes in quotes for strings?
Needing to double + single quote everything feels really fiddly and clumsy, like, I feel like I don't my coworkers to see this code lest they judge me.
Is there a cleaner, alternative syntax/api?
14 Replies
It's better with syntax highlighting, download the extension.
Also, in the docs we do have, I m ention
type.enumerated
so you can use that if you prefer@ArkDavid ok i figured out the
type.enumerated
for intial definition, but I'm still struggling with a bit, see below:
I don't use vscodeAhh RIP
I also worry about ability to use refactoring tools with stuff being strings
sure, the compiler will complain but I'd prefer if I didn't have to think about writing an additional regex for find/replace after every refactor
ahh got it.
targets: [type.unit('BODY'), type.unit('FACE')],
might be good to have some shorthand aliases for type.enumerated()
and type.kind()
, they're a bit wordyThen make them lol
yeah of course I can add them myself
You may find this hard to believe but I have put orders of magnitude more thought into every decision related to this library than all these random suggestions so if something is a particular way, it's probably not because I didn't think of an alternative name for the API
oh I believe it
Then please, I would find it a lot easier to help out where I can if you stopped suggesting changes based on the first thoughts you have using the library
ok
Though to be clear, the previous suggestion was not a request to rename
enumerated
or unit
, these are good names and are plenty clear now I see how they are used, my suggestion was to add some additional short aliases (like $
) in the interest of making the fluent api feel comparable to the nice and terse string api. Though now i say it, I'm sure you have considered this too.
I will limit the suggestions going forward. My apologies, and thank you for all your help and patience thus far.
I just get excited about new toolsThank you, I appreciate that! I don't anticipate most people using literals so frequently as I think the types you are trying to build are a bit unique, but I can see how it could get a bit verbose. Feel free to destructure/rename
enumerated
and/or unit
from type.
As far as refactoring, one general strategy is to create an object, then use a narrowed Object.keys
which you can pass to type.enumerated
(or anywhere really, it can just be a good native alternative to an enum in TS)
Also I'm looking for someone who uses neovim to add support for ArkDark's textmate scopes which I think makes a huge difference for DX so let me know if you're interested in tackling thatlet me know if you're interested in tackling thatah that would be neat, but no bandwidth for it currently
As far as refactoring, one general strategy is to create an object, then use a narrowed Object.keys which you can pass to type.enumerated (or anywhere really, it can just be a good native alternative to an enum in TS)This is basically what TS
enum {FOO = 'FOO' }
compile to, no?Not exactly. A lot of people wouldn't recommend enums in modern TS because they're a bit opaque externally
that's definitely true for numeric enums, you end up passing around a lot of mysterious 0s and 1s and 2s
but I struggle to follow that for the newer stringy enums, they're just strings on an object
but yeah ok good to know