minecraft-server icon indicating copy to clipboard operation
minecraft-server copied to clipboard

NBTify Anvil Parsing + Types

Open Offroaders123 opened this issue 1 year ago • 2 comments

Offroaders123 avatar Feb 13 '24 00:02 Offroaders123

Quick question, what's the point of declaring fields with quotes around enum type like

type MyType = {
  resource: `${DimensionResource}`
}

instead of just

type MyType = {
  resource: DimensionResource
}

?

peacefulotter avatar Feb 13 '24 07:02 peacefulotter

I use an enum to define the types for resource IDs in a single place, and if the enum is declared plainly as the type itself, then it won't let you get autocompletion for the string values themselves, which is the approach I like to have out of the box, in terms of editor UX. It does still let you put in those plain strings without needing to reference them from the enum as a key itself, but I want it to get that nice autocomplete that shows plain strings as an option as well.

tldr: It makes the enum's values appear like a union of strings when using editor autocomplete.

Autocomplete Demo

Offroaders123 avatar Feb 14 '24 03:02 Offroaders123