Skip to content

Instantly share code, notes, and snippets.

@Nate-Wilkins
Created October 25, 2018 20:24
Show Gist options
  • Save Nate-Wilkins/43a3bd7e93e54a8595d3140c282749bc to your computer and use it in GitHub Desktop.
Save Nate-Wilkins/43a3bd7e93e54a8595d3140c282749bc to your computer and use it in GitHub Desktop.
FlowJS hackery to filter down arrays to specific types.
type A = {
a: number
};
const myA: A = { a: 1 };
const ac = [undefined, myA];
const ba: $ReadOnlyArray<A> = ac.filter(Boolean);
const c = (justAs: $ReadOnlyArray<A>) => console.log(justAs);
c(ba);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment