Bird
0
0

Which syntax correctly imports a module that can be tree shaken in Angular?

easy📝 Syntax Q12 of 15
Angular - Performance Optimization
Which syntax correctly imports a module that can be tree shaken in Angular?
Aimport * as Component from '@angular/core';
Bimport Component from '@angular/core';
Crequire('@angular/core').Component;
Dimport { Component } from '@angular/core';
Step-by-Step Solution
Solution:
  1. Step 1: Recognize ES module import syntax

    Angular uses ES module syntax: import { NamedExport } from 'module';
  2. Step 2: Identify correct import for Component

    The correct syntax is importing Component as a named export inside curly braces.
  3. Final Answer:

    import { Component } from '@angular/core'; -> Option D
  4. Quick Check:

    Correct ES module import = import { Component } from '@angular/core'; [OK]
Quick Trick: Use curly braces for named imports in Angular [OK]
Common Mistakes:
  • Using default import syntax for named exports
  • Using CommonJS require instead of ES import
  • Importing everything as a namespace unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes