Bitpath

Lesson 2 · Unit 04

Types and linters

Checks that read your code without running it, and what they miss

12 exercisesabout 3 min

What you practise

  • What a type checker catches before any test runs, what it can't, any as an escape hatch, linters and formatters, the layers of defence

Try a question from this lesson

Pick one

A width arrives as text from a form field. No error is raised anywhere. What does this print?

def area(w, h):
    return w * h

print(area("3", 4))
function area(w, h) {
  return w * h;
}

console.log(area("3", 4));
function area(w: number, h: number) {
  return w * h;
}

const input: any = "3";
console.log(area(input, 4));

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Checks that never run your code

Some tools find mistakes by reading code instead of running it.

A type checker proves that each value is the kind its user expects: no text where a number belongs, no missing argument.

A linter flags patterns that are usually mistakes: a variable never used, a line that can never run.

Both are fast and cover every line, even lines no test visits. Neither knows what your program is supposed to do.

10 more exercises in the app

  • 5× multiple choice
  • 1× fill the blanks
  • 1× true or false
  • 1× type the answer
  • 1× match the pairs
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy