Thanks for the post. Is there documentation on that typeof myConst[number] syntax? Specifically the [number] part is something i've never seen in typescript, and can't find on the doc site.
typeof myConst[number]
[number]
Hi, I'm not sure. Been a while since I wrote this and its a gathering of things I read and things I just tested with code...
New TS Handbook has a mention about [number] syntax:
const MyArray = [ { name: "Alice", age: 15 }, { name: "Bob", age: 23 }, { name: "Eve", age: 38 } ]; type T = (typeof MyArray)[number];
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the post. Is there documentation on that
typeof myConst[number]
syntax? Specifically the[number]
part is something i've never seen in typescript, and can't find on the doc site.Hi, I'm not sure. Been a while since I wrote this and its a gathering of things I read and things I just tested with code...
New TS Handbook has a mention about
[number]
syntax: