Q35. What is a type-only import?

import type marks imports used only for types. It clarifies the runtime dependency graph and is erased from emitted JavaScript. Use it when a symbol is not needed as a runtime value.

Mixing type and value imports can be supported with inline type modifiers depending on the syntax and toolchain.

Note

Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.

TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";
💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
  • Explain the concept in your own words.
  • Know the practical trade-off and its limits.
  • Use a small example to demonstrate the idea.
Knowledge Check

Which import is type-only?