dsherret / dsherret/ts-morph

Question: How to know if import statement is importing only interfaces and types?

Open
#1,313 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

Let's consider there is a file named: `grid.ts`

```ts
export interface GridInterface {

}

export type GridType = 'simple' | 'advanced';

export class GridComponent {

}

```

Now import this file in another file as shown below:
`dashboard.ts`

```ts
import { GridInterface, GridType } from 'grid';
```

My question:
Is there any way to check that the import statement is importing only interfaces and types and not any class/function/variable etc.?

Asking because I am writing a dependency path finder script and in that, I need to ignore import statements that only include types/interfaces because such imports do not have any impact in the transpiled code.

Contributor guide

Open the contributing guide

Research direction

Start with the grid.ts and dashboard.ts examples in the issue and review how the repository represents imports for static analysis. The work is complete when the dependency path finder can reliably distinguish imports containing only interfaces or types from imports that affect transpiled code, with the result documented or demonstrated in the relevant entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.