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
In statement ignoredKeys.includes(key), error Argument of type 'string' is not assignable to parameter of type 'keyof DataClass'
In statement dcInstance[key], error Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'DataClass'. No index signature with a parameter of type 'string' was found on type 'DataClass'.
const key is typed as "string"
π Expected behavior
The statement ignoredKeys.includes(key) should not throw any type errors. The Array.includes() method should accept strings as arguments when all items stored in the ignoredKeys array are string keys.
Other expected behavior, but not important at all : - Variable key should be of type keyof typeof dcInstance instead of "string" - No type errors in statement dcInstance[key]
Additional information about the issue
I have an entity and would like to iterate over the keys of that object, excluding some keys.
The text was updated successfully, but these errors were encountered:
π Search Terms
"typescript for in string" "typescript keyof for in" "array includes keyof"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/MYGwhgzhAEAiYBcwGFxWgbwFDV9ADgK4BGIAlsNGAPwBc0ECATmQHYDmA3DnkaRdGJ1orQgFtiAUybcAvlmAB7Vo2hl2rRU0kATANKSAnjHoAKANZHFAMziIUaCAEoA2gF1oAXjwuA5GF83bgVlVR1gAEkVJFZgSS8RSQB3OyRUSAhTJ25wqMYwWMkAOjAEgCJlSTKcyOiCuKLiBIAmbmstaFMlaOhLQzVWaFy6wqdMHlwyW1MAQnVNbX0jCCK2UEIdSUy+pzHsPAPobohFEGKQRXZTMuH8wpcAUggPbyeygBpeo0+AZWY2K63GJxFx9Ny7bgHeTyLBAA
π» Code
π Actual behavior
Actual behavior :
ignoredKeys.includes(key)
, error Argument of type 'string' is not assignable to parameter of type 'keyof DataClass'dcInstance[key]
, error Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'DataClass'. No index signature with a parameter of type 'string' was found on type 'DataClass'.const key
is typed as "string"π Expected behavior
The statement
ignoredKeys.includes(key)
should not throw any type errors. TheArray.includes()
method should accept strings as arguments when all items stored in theignoredKeys
array are string keys.Other expected behavior, but not important at all :
- Variable
key
should be of typekeyof typeof dcInstance
instead of "string"- No type errors in statement
dcInstance[key]
Additional information about the issue
I have an entity and would like to iterate over the keys of that object, excluding some keys.
The text was updated successfully, but these errors were encountered: