0

So the following works fine when I put in break point in the code and run the following: [browser console] enter image description here

but I get Type 'string[]' cannot be used as an index type when I try to use in typescript.

enter image description here

2
  • try converting the value to a string. Commented Nov 29, 2020 at 18:46
  • convert string [] > to string works but doesnt give me what the javascript above gets me. Im going through an object with dynamic keys Commented Nov 29, 2020 at 19:53

1 Answer 1

1

JavaScript will let you do stupid things and won't tell you it doesn't make sense. But typescript will warn you. It's much more strict about writing coherent code. You effectively did this:

[1][[0]] // 1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.