

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Function Type Syntax
incomplete
2: Inferred Return Types
incomplete
3: Void
incomplete
4: Function Types
incomplete
5: Type Alias
incomplete
6: Importing Types
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
With certain TypeScript configurations you can import types directly from a module:
import { User, Post } from "./models";
But it's much safer and more efficient to use the import type syntax:
import type { User, Post } from "./models";
This way TypeScript knows that you're only importing types, and it can drop the imports so they don't generate extra JavaScript code when your project is compiled. This means a smaller final bundle size. This syntax also works:
import { type User, type Post } from "./models";
But personally I prefer the first one. It's more concise and keeps all my type imports in one place.