Concept Flow - Import syntax variations
Start
Choose import type
Default
Import default
Use imported
End
This flow shows how TypeScript imports can be default, named, or namespace style, then used in code.
import React from 'react'; import { useState } from 'react'; import * as Utils from './utils';
| Step | Import Statement | Import Type | Imported Identifier | Source Module | Usage Example |
|---|---|---|---|---|---|
| 1 | import React from 'react'; | Default | React | 'react' | React.createElement(...) |
| 2 | import { useState } from 'react'; | Named | useState | 'react' | const [state, setState] = useState() |
| 3 | import * as Utils from './utils'; | Namespace | Utils | './utils' | Utils.helperFunction() |
| 4 | End of imports | - | - | - | - |
| Identifier | Start | After Import |
|---|---|---|
| React | undefined | object (default export from 'react') |
| useState | undefined | function (named export from 'react') |
| Utils | undefined | object (all exports from './utils') |
Import syntax variations in TypeScript:
- Default import: import React from 'module';
- Named import: import { name } from 'module';
- Namespace import: import * as alias from 'module';
- Can combine default and named: import React, { useState } from 'module';
- Use imported identifiers directly in code.