Repository: babel/babel (TypeScript)

Issue:
[Bug]: onlyRemoveTypeImports: true should not remove imports with only inline type specifier
### 💻

- [ ] Would you like to work on a fix?

### How are you using Babel?

@babel/cli

### Input code

```ts
import { type T } from "./mod";
```

### Configuration file name

babel.config.json

### Configuration

```json
{
  "presets": [
    ["@babel/preset-typescript", { "onlyRemoveTypeImports": true }]
  ]
}
```

### Current and expected behavior

Current behavior:

```ts
// empty
```

Expected behavior / tsc with `"isolatedModules": true` and `"importsNotUsedAsValues": "error"`:

```ts
import "./mod";
```

### Environment

```
  System:
    OS: Linux 6.1 Arch Linux
  Binaries:
    Node: 19.3.0 - /usr/bin/node
    Yarn: 4.0.0-rc.35 - ~/.local/bin/yarn
    npm: 8.19.2 - /usr/bin/npm
  npmPackages:
    @babel/cli: ^7.20.7 => 7.20.7 
    @babel/core: ^7.20.12 => 7.20.12 
    @babel/preset-typescript: ^7.18.6 => 7.18.6 
```

### Possible solution

_No response_

### Additional context

https://github.com/microsoft/TypeScript/issues/47118#issuecomment-993047937


Hints:
Hey @latin-1! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant [Slack community](https://babeljs.slack.com) that typically always has someone willing to help. You can sign-up [here](https://slack.babeljs.io/) for an invite.
Minimal tsc repro:

```jsonc
// tsconfig.json
{
  "compilerOptions": {
    "module": "ESNext",
    "isolatedModules": true,
    "importsNotUsedAsValues": "error"
  }
}
```

```ts
// index.ts
import { type T } from "./mod";
```

```ts
// mod.ts
export type T = number;
```

#### Output

```js
// index.js
import "./mod";
```

```js
// mod.js
export {};
```

Patch:
diff --git a/packages/babel-plugin-transform-typescript/src/index.ts b/packages/babel-plugin-transform-typescript/src/index.ts
--- a/packages/babel-plugin-transform-typescript/src/index.ts
+++ b/packages/babel-plugin-transform-typescript/src/index.ts
@@ -346,7 +346,7 @@ export default declare((api, opts: Options) => {
                 }
               }
 
-              if (isAllSpecifiersElided()) {
+              if (isAllSpecifiersElided() && !onlyRemoveTypeImports) {
                 stmt.remove();
               } else {
                 for (const importPath of importsToRemove) {


Test patch:
diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/only-remove-type-imports/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/only-remove-type-imports/output.mjs
--- a/packages/babel-plugin-transform-typescript/test/fixtures/imports/only-remove-type-imports/output.mjs
+++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/only-remove-type-imports/output.mjs
@@ -5,5 +5,6 @@ import d, { d2 } from "d";
 import e, { e3 as e4 } from "e";
 import "f";
 import "g";
+import "k";
 import { L2 } from "l";
 ;
diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/type-only-import-specifier-4/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/type-only-import-specifier-4/output.mjs
--- a/packages/babel-plugin-transform-typescript/test/fixtures/imports/type-only-import-specifier-4/output.mjs
+++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/type-only-import-specifier-4/output.mjs
@@ -0,0 +1 @@
+import "x";