|
|
|
|
|
by throwaway284534
1709 days ago
|
|
You’re right that this is really easy to mess up, especially when defining an array index e.g. const todos: string[] = [“walk dog”];
todos[123].toUpperCase() // error!
IMO non constant (as defined by TypeScript) arrays should’ve been automatically assigned a union type with `undefined`, which can also be a fix for Records too: type Tips = Record<string, TipObject | undefined>
|
|