Hi, I'm having a little trouble with .filter while specifying the return value. I have something like this:
[
this.getHexagonAt(col, row, 'RIGHT'),
this.getHexagonAt(col, row, 'TOP_RIGHT'),
this.getHexagonAt(col, row, 'TOP_LEFT'),
this.getHexagonAt(col, row, 'LEFT'),
this.getHexagonAt(col, row, 'BOTTOM_LEFT'),
this.getHexagonAt(col, row, 'BOTTOM_RIGHT')
].filter(Boolean);
Where getHexagonAt return type is Hexagon|null. I'm passing the Boolean function to filter out all null values, so that all I get is an array with Hexagon (or empty). But TypeScript keeps yelling at me saying that the return value is possibly null.
The code runs correctly and as expected, it's just the typing that is giving me trouble. How can I work around this? Thanks!