Narrowing arrow types with Array.filter and TypeScript

  1. Using filter<type> to specify the type we’re narrowing down to.
  2. Defining the filter function as a user defined type guard using (thing): thing is number .

--

--

--

Full stack web developer, typescript evangelist, human

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Client Logging In Javascript

How to Structure a Vue.js Project

How To Secure Your Node.js Applications

Toy robot

How to Cut Development Time In Half?

Browser dialog and notifications with Angular and Alertify JS

How many ways to redirect the user in the next.js app?

How to redirect the user in next.js

Interview Preparation —Tricky Questions-1

11 JavaScript Examples to Source Code That Reveal Design Patterns In Use

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mark Slade

Mark Slade

Full stack web developer, typescript evangelist, human

More from Medium

Typescript Numeric Range Type

What’re the Interfaces in TypeScript, and What’s the Difference Between Type Aliases and Interfaces?

What is Typescript

How to configure Jest with TypeScript