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 is not possible to create a type, that has an index type + properties of a different type:
typeA{[key: string]: number;
foo: string}// error
However, this case is not unsual and should be considered.
To achive that, it is needed to remove certain keys from the index.
In the definition above, this could simply be done by removing all defined keys (in this caseonly "foo") from the index automatically.
Removing keys from the index is also useful if you wanna add attributes with different type:
(a similar issue for that example is here: #49867)
π Motivating Example
I guess I cramped all infos into the summary, I am sorry
π» Use Cases
Atm, mixing index types with other types is almost impossible. If you know, that you get an object that has certain typed values but also know that ONE keys is always set and different, you cannot type this properly atm because you cant have an index type + a different other key.
The text was updated successfully, but these errors were encountered:
Suggestion
π Search Terms
index type, omit keys
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
It is not possible to create a type, that has an index type + properties of a different type:
However, this case is not unsual and should be considered.
To achive that, it is needed to remove certain keys from the index.
In the definition above, this could simply be done by removing all defined keys (in this caseonly "foo") from the index automatically.
Removing keys from the index is also useful if you wanna add attributes with different type:
We could even go as far as making this work:
A differen way of doing this without as much possibilities is to allow for negated matches in string literals:
(a similar issue for that example is here: #49867)
π Motivating Example
I guess I cramped all infos into the summary, I am sorry
π» Use Cases
Atm, mixing index types with other types is almost impossible. If you know, that you get an object that has certain typed values but also know that ONE keys is always set and different, you cannot type this properly atm because you cant have an index type + a different other key.
The text was updated successfully, but these errors were encountered: