Type functions, when passed `typeof(table)`, has no properties if that table is manipulated by a for loop

Using the new type solver, type functions don’t behave correctly when you pass typeof(table). The table could be anything, but if it gets modified by a for loop, the type function returns an unresponsive type (no autocomplete, but also no error-type symbol).

sameConfig should be exactly the same type as config in both of these scenarios.

I thought that somehow the typeof(config) type was being messed up, but no, it’s still intact.

This type function is quite simple! When you use generics to do the exact same thing, generics work.

Expected behavior

I expect type functions to work when the table type that is passed is modified using a loop. Even when the loop sets each key to what it was already set to, the type function errors and provides no autocomplete.

The config table is still working even when modified.

The i and v in the for loop are *error-type*.

config has an *error-type* key-value pair, like sameConfig does. Despite this, using generics or typeof(config) directly still work. It’s only type functions that have a problem with this!

Thank you for the report! Agreed, this seems like a bug: at best we should be inferring that config has some indexer, definitely not *error-type* in this case.

1 Like