import type
`import type` brings in a type from another module and tells TypeScript the import exists only for type checking.
A type (an interface, a type alias) only lives while tsc checks your code. When Node runs the file, types are gone.
That is why import type { Todo } from "./todo-store.ts" is erased completely at run time. Node never loads that import. If you wrote a normal import for something that is only a type, Node would look for a value that does not exist and could fail.
With import type you state your intent: this is only a type. If you later try to use it as a value (call it, create an instance), tsc tells you.
The syntax is a normal import with the word type after import. In the course you will see it in many lessons, like import type { Todo } from "./todo-store.ts";, to bring in types from your own modules.
Reach for it when: you import something that is only used as a type: an `interface`, a type alias, or a parameter's type.
Examples
Common mistake
import type { parse } from "node:path";
console.log(parse("/tmp/a.txt").name);Why: With `import type` you tell TypeScript that `parse` is for types only. Since it is erased at run time, you cannot call it as a function.
How to write it: Use a normal import for values: import { parse } from "node:path";.
