File Imports

Since managing package imports is a common task, Grit includes standard patterns for declaratively adding, removing, and updating imports.

ensure_import_from

This pattern ensures that the given $value is imported from the given $source (adding the import if it does not exist).

Note: because this is a pattern you must match some $value against it.

PATTERN
`class $_ extends $comp { $_ }` where {
  $comp <: `Component`,
  $source = `"React"`,
  $comp <: ensure_import_from($source)
}
INPUTOUTPUT
class Button extends Component {
  // ...
}
import { Component } from 'React';

class Button extends Component {
  // ...
}