Search Terms
Indexing, Array, Strict check
Suggestion
Strict check to indexing a array
Use Cases
Safety with arrays usages
Examples
const arr: House[] = .... // same as [] | House[]
arr[0] // throw error
if(arr.length > 0) {
arr[0] // OK
arr[200] // throw error
}
const arr2: [House, House] = ...
arr[0] // OK
arr[1] // OK
Checklist
My suggestion meets these guidelines:
Search Terms
Indexing, Array, Strict check
Suggestion
Strict check to indexing a array
Use Cases
Safety with arrays usages
Examples
Checklist
My suggestion meets these guidelines: