fewkz / froact

Wrapper around Roact & Roact Hooks to simplify UI development and add full, correct Luau typing
MIT License
3 stars 0 forks source link

Change default children type to `{[string]: any}` #10

Open fewkz opened 1 year ago

fewkz commented 1 year ago

Right now, the children type is set to {any}, this means that froact is OK with you not giving each child in the children a string key. By changing this to {[string]: any} this would catch a lot of issues where you accidentally forget to write the name of the child you're going to make, which causes the children to be named with sequential numbers, which is super annoying to read in the explorer. However, having to write the name of every children sucks a lot and a lot of existing froact code would probably turn into a lot of errors without a clear reason why. This is semi-related to #9

fewkz commented 1 year ago

Nvm, this isn't even possible unless we give Element a more definitive type, since it's currently typed as any image

fewkz commented 1 year ago

This is the following code we'd need to change. https://github.com/fewkz/froact/blob/c9790a07feaea1ef6a598c0471ad8a12752251b0/froact.lua#L25-L27 We currently have it so you can pass a single child in the second argument to anything. This is cool, but stylua really doesn't like it: image

It might be worth it to deprecate this feature, with the benefit of allowing us to type children as {[string]: any} in order to catch more headaches before they occur.