I find myself using `{[key: string]: mixed}` so much for dynamicish data that I feel like Flow/TypeScript should make it a built-in.
-
-
Just looked at the first project I put that in. Here are the types: export type NumericallyKeyed<T> = { [index: number]: T, }; export type Dict<T> = { [index: string]: T, }; NumericallyKeyed lets you do keyof on an Array without getting method names.
-
Hold on... Wouldn't the first type... just be an array? Where would you specifically need a type with a number index without it being at least ArrayLike?
- 5 more replies
New conversation -
-
-
Lodash types include a dictionary type. Really useful.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Dict is an importable type from lodash, too.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 