acrazing/dpdm

Ignore import type

fysntian opened this issue · 2 comments

Typescript allows "import type" for just a type require, and it will be ignored in complied .js file. My codes is here:

// file /contexts/task-request-context.ts:
import type Task from '../models/task.model';

// file /models/task.model.ts
import TaskRequestContext from '../contexts/task-request-context';

And I think they won't be Circular Dependencies.

dpdm/README.md

Lines 73 to 77 in 579a35f

4. Ignore type dependencies for TypeScript modules
```bash
dpdm -T ./src/index.ts
```

@andrejpavlovic You are awesome.

@fysntian You can add the flag -T to ignore type references when you run dpdm.

TypeScript hides many internal APIs, includes the method to detect a value import is type reference or value reference. So dpdm drops the type references by transform TypeScript file to JavaScript file violently. It will drop both type imports and value imports only reference types.