# ImportBase

CLASS in `@skmtc/core 0.63.4`

The language-neutral contract for a registered import.

A `@skmtc/lang-*` package provides a concrete subclass (`TsImport`,
`GoImport`, …) that owns the language's import shape and rendering. The
engine and `CodeFileBase` only ever
see this neutral surface:

- `mergeKey()` - identity for dedup AND the handle a `File` uses to
  arrange its import section (typically the module / package path). Two
  imports with the same key collapse via `merge`.
- `merge(other)` - combine a same-key import into this one (e.g. union
  their symbols). The subclass narrows `other` to its own type.
- `toString()` - render the standalone import. A language `File` MAY
  re-arrange instead (e.g. Go groups every package into one
  `import ( … )` block keyed by `mergeKey()`), so `toString()` is the
  per-import render, not the whole section.

The split is deliberate: the *merge* of imports is language-neutral (it
lives on `CodeFileBase`); the *arrangement* of the import section is
language-specific (it lives in the concrete `File.toString()`).

## Signature

```ts
import { ImportBase } from '@skmtc/core'

abstract class ImportBase
```

## Methods

### mergeKey

```ts
mergeKey(): string
```

Identity for dedup and arrangement - typically the module or package
path. Imports sharing a `mergeKey()` are merged via `merge`; a
`File` may also group or sort its imports by this key.

### merge

```ts
merge(other: ImportBase): ImportBase
```

Combine another import that shares this `mergeKey()` into a single
import. The concrete subclass narrows `other` to its own type (and
throws if handed a foreign import - which only happens if two languages
wrote to one file, a misconfiguration).

### toString

```ts
toString(): string
```

Render the standalone import. The `File` may re-arrange via `mergeKey`.
