Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamiemason/ts-import-types-cli
Autofix TypeScript types to be imported using `import type`
https://github.com/jamiemason/ts-import-types-cli
cli codemod codemods jscodeshift refactor refactoring-tools ts-morph type-only-imports typescript
Last synced: about 7 hours ago
JSON representation
Autofix TypeScript types to be imported using `import type`
- Host: GitHub
- URL: https://github.com/jamiemason/ts-import-types-cli
- Owner: JamieMason
- Created: 2020-12-12T18:39:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-29T17:37:45.000Z (about 1 year ago)
- Last Synced: 2024-10-03T06:58:02.453Z (about 12 hours ago)
- Topics: cli, codemod, codemods, jscodeshift, refactor, refactoring-tools, ts-morph, type-only-imports, typescript
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 40
- Watchers: 3
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# ts-import-types-cli
> Autofix TypeScript types to be imported using `import type`
## Installation
```
npm install -g ts-import-types-cli
```## Usage
```
Usage: ts-import-types-cli [options] [patterns...]Options:
-V, --version output the version number
-d, --dry-run write output to stdout instead of overwriting files
-p, --project [path] path to tsconfig.json
-O, --no-organise-imports disable use of VS Code's organise imports refactoring
-h, --help display help for command
```## Example
```
$ ts-import-types-cli --project ./tsconfig.json 'src/**/*.ts' 'src/**/*.tsx'
``````ts
import { interpret, StateValue } from 'xstate';
import { sendSearch } from '../../services/search-client/send-search';
import { createAlgoliaMachine } from '../machine';
import { AlgoliaInterpreter, AlgoliaMachine } from '../machine/types';// ...the rest of the file
↓↓↓↓↓
``````ts
import type { StateValue } from 'xstate'
import { interpret } from 'xstate'
import { sendSearch } from '../../services/search-client/send-search'
import { createAlgoliaMachine } from '../machine'
import type { AlgoliaInterpreter, AlgoliaMachine } from '../machine/types'// ...the rest of the file
```## Triple-Slash Directives
Moving triple-slash directives such as `/// ` back
to the top of the file is not yet supported. If you know how to do this using
https://ts-morph.com please [open a
PR](https://github.com/JamieMason/ts-import-types-cli/pulls) or otherwise let me
know.Unfortunately until then, files will need their triple-slash directives manually
moving back to the top of the file.`ts-import-types-cli` will output a list of which files are affected.