ts-format-imports

Typescript import formatter

Usage no npm install needed!

<script type="module">
  import tsFormatImports from 'https://cdn.skypack.dev/ts-format-imports';
</script>

README

ts-format-imports

Build Status Coverage Status

TypeScript import formatter powered by TypeScript Compiler API.

Installation

npm install -g ts-format-imports

Usage

$ ts-format-imports file1.ts file2.ts file3.ts

The command above will reformat import declarations and remove duplicate imports from the specified files.

For example, this:

import {foo, bar} from 'modules/foo';
  import {bar} from 'modules/foo';
    import * as ts from 'typescript';
import {doSomething} from 'modues/boo';

after reformatting would look like

import * as ts from 'typescript';

import {doSomething} from 'modues/boo';

import {bar} from 'modules/foo';
import {foo} from 'modules/foo';