An import statement declares an ECMAScript module’s dependency on another module. Variables are private to a module unless exported; an import makes those exports available under local names. Unlike `import()`, which runs asynchronously at runtime, a static import is handled when the module is parsed. section 13.1.1 section 13.1.2
Import only the names you need
If a module exports `homeIsland` and `getOccupation`, write `import { homeIsland, getOccupation as getTitle } from "./1-export-syntax.ts";`. The braces resemble object destructuring, but this is module syntax. `as` gives the imported binding a local name—useful when two modules export the same name. section 13.1.1
Choose the form that matches the dependency:
- `import hero, { tsundere } from "./4-default-export.ts";` combines a default import with a named import. The default export can also be named explicitly with `default as hero`. section 13.1.1
- `import * as characters from "./4-default-export.ts";` gathers exports into a namespace; its default export is accessed as `characters.default`. section 13.1.1
- `import "./scripts/ninja.js";` executes a module without importing any names. This is a side-effects import. section 13.1.1 section 13.1.2
Imports are live bindings, not snapshots: if the exporting module reassigns an exported value, an importer reads the new value. The importer cannot reassign that binding itself. An imported dice-roll result, for example, changes after calling the exported roll function. section 13.1.1 section 13.4
The specifier after `from` must resolve in the environment running the code. Node.js package `exports` can map a package name or subpath to files; a browser import map can map a bare name to a URL. In Node.js, `.mjs` identifies ESM, while a package’s `"type": "module"` can mark its files as ESM. When importing a `.ts` path directly in the shown TypeScript setup, type-checking requires `allowImportingTsExtensions` with `noEmit`. section 13.1.1 section 3.1.2 section 13.1.2













