Q48. What does target control?
target selects the JavaScript language version emitted by the compiler, influencing which syntax is transformed. It does not itself determine all runtime APIs available; library definitions and the actual runtime environment matter too.
A newer target can preserve modern syntax, but developers must still ensure the deployment runtime supports the APIs used.
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
Does setting target to ES2022 automatically polyfill every missing runtime API?