You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the compiler fails to use variables declared by a tuple as index keys. For those of you looking for a workaround in the meantime: redefine your tuples to rather be normal variables (using Object.keys and Object.values for above example) instead.
An alternative, potentially a bit more type-friendly workaround (e.g. when using noUncheckedIndexedAccess ) is to keep using Object.entries() but destructure the entries in a separate statement.
Activity
will-path commentedon Apr 7, 2025
I'm also hitting this. Here's the MRE: https://www.typescriptlang.org/play/?#code/C4TwDgpgBAwg9gO2AQwJYIgJwDwGkIgDOUEAHsBAgCbGHCboDmAfFALxQDeAUFFANr4QUdFCGEAugC4oAIzhwANhGQIA3NwC+3bgGNEdKPoR1VwGfCRoMOAEQAzBbagAfKLdnJMt1hx59HOBl6AFcIABpeOS8Ze2RFQgitHXsQhF1gVEQoKhAEZABbVF08AmIyCmpaeiZmAAp7VEw6GXFw6MYZAFlkMFKidvklFQRmAEoLRBR0LH7CVn8oZWAoTAhCEMVzWCnrWfFWNzSqCEaMKnYoY9OZqg0ox0woOuNDfgBrAnaAN3iwiSgcHsHQAdJQaus6mMxlwonxUMC6gBCNYbLYw1GbFZ+ASfEDSKC-RRhKCaDR8PgQBLQTFbD4EAEcIlhcmknR8NbAEKYBCrdZYjTabi5fJFXR1BxOdoYADuUB6YDq-H4krgtnaoQgEnaKs83nacWpEgk0KAA
lnunno commentedon May 28, 2025
Wondering what the status of this one is and if the linked PR can be reviewed / merged?
RudiVuuren commentedon Jun 4, 2025
It seems the compiler fails to use variables declared by a tuple as index keys. For those of you looking for a workaround in the meantime: redefine your tuples to rather be normal variables (using
Object.keysandObject.valuesfor above example) instead.Workaround
Before
After
martinslota commentedon Jun 17, 2025
An alternative, potentially a bit more type-friendly workaround (e.g. when using
noUncheckedIndexedAccess) is to keep usingObject.entries()but destructure the entries in a separate statement.Before
After