cocopon / tweakpane

:control_knobs: Compact GUI for fine-tuning parameters and monitoring value changes
https://tweakpane.github.io/docs/
MIT License
3.57k stars 90 forks source link

`view` string autocomplete. #578

Open braebo opened 11 months ago

braebo commented 11 months ago

Right now, the view option is typed as string, which provides no autocomplete:

folder.addBlade({
  view: '', // no autocomplete
})

I think a union of string literals would be awesome to have here. This would make it easy to see what the available views are without having to surf the docs every time.

If it was instead typed like this:

type View = 'color' | 'list' | 'graph' | ...etc | ({} & string)

The ({} & string) would allow any string value, but the type would preserve the intellisense for autocomplete!

I think this could also be used to infer the type of the binding returned using conditional types internally... but that is another issue altogether 😇

cocopon commented 11 months ago

Interesting. Do you know how it works? It looks a bit cryptic and I still can't understand why it works as intended.

braebo commented 11 months ago

Yea it's a weird one!

You can read more about it in these stack overflow posts:

https://stackoverflow.com/a/61048124 https://stackoverflow.com/a/75265010