New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The .filter(Boolean)
doesn't seem to be working as expected
#146
Comments
There is some weirdness with function makeRows({
row1,
row2,
row3,
row4,
row5,
}: {
row1?: number[];
row2?: number[];
row3?: number[];
row4?: number[];
row5?: number[];
}) {
let rows = [row1, row2, row3, row4, row5];
rows = rows.filter(Boolean);
//^? let rows: (number[] | undefined)[]
// But I expect number[][]
} Am I missing something? EDIT: let rows = [row1, row2, row3, row4, row5].filter(Boolean);
// ^? let rows: number[][] I guess because the type inference carries down from the initial delcaration |
@JakeTrevor Sorry, the example I gave may have some problems. const numbers = [1, 0, false, null, undefined].filter(Boolean) |
Closing, @JakeTrevor is correct. |
TS Playground
The text was updated successfully, but these errors were encountered: