Repository: depcheck/depcheck (js)

Issue:
Handle array `extends` in tsconfig
### Bug Description

The TSConfig parser pushes the whole `extends` value https://github.com/depcheck/depcheck/blob/77fe0e2d092bdc8b97b65e37955f59be8a436d19/src/parser/tsconfig.js#L24-L26

It should check if it's an array and push each element separately.

### Code snippets

Where the dependency is used:

```
// a tsconfig.json file for a part of the project
{
  "extends": ["../../tsconfig.defaults.json", "@tsconfig/create-react-app"],
  ...
}
```

Where the dependency is listed in package.json:

```
    // dependencies
    "@tsconfig/create-react-app": "^1.0.3",
```

### Versions

- `node -v`: 18.17.0
- `npm -v`: 9.6.7
- `depcheck --version`: 1.4.7

### Extra info

Any extra info you want to include. Thank you for the bug report!

BONUS POINTS: If you wish to help us debug further, the `depcheck --json` option will show more information. Check [here in the README](https://github.com/depcheck/depcheck#example) for documentation on json output.


Pull request:
fix: Handle array extends in tsconfig
Fix #854

Patch:
diff --git a/src/parser/tsconfig.js b/src/parser/tsconfig.js
index 9a4f15f..6b20051 100644
--- a/src/parser/tsconfig.js
+++ b/src/parser/tsconfig.js
@@ -24,7 +24,11 @@ export default function tsconfigParser(filePath, deps) {
   }
 
   if (tsconfigJson.extends) {
-    foundDeps.push(tsconfigJson.extends);
+    if (Array.isArray(tsconfigJson.extends)) {
+      foundDeps.push(...tsconfigJson.extends);
+    } else {
+      foundDeps.push(tsconfigJson.extends);
+    }
   }
 
   const plugins = tsconfigJson.compilerOptions?.plugins;


Test patch:
diff --git a/test/fake_modules/tsconfig/package.json b/test/fake_modules/tsconfig/package.json
index 2f262ed..a45687d 100644
--- a/test/fake_modules/tsconfig/package.json
+++ b/test/fake_modules/tsconfig/package.json
@@ -3,6 +3,7 @@
   "dependencies": {},
   "devDependencies": {
     "@mybrand/tsconfig": "*",
+    "@tsconfig/recommended": "*",
     "@types/node": "*",
     "@types/unused": "*",
     "typescript-eslint-language-service": "*"
diff --git a/test/fake_modules/tsconfig/tsconfig.array-extends.json b/test/fake_modules/tsconfig/tsconfig.array-extends.json
new file mode 100644
index 0000000..6c1f7b6
--- /dev/null
+++ b/test/fake_modules/tsconfig/tsconfig.array-extends.json
@@ -0,0 +1,3 @@
+{
+  "extends": ["tsconfig-base/tsconfig.base.json", "@tsconfig/recommended"]
+}
diff --git a/test/spec.js b/test/spec.js
index cc311a9..a97031a 100755
--- a/test/spec.js
+++ b/test/spec.js
@@ -248,14 +248,15 @@ export default [
       missing: {
         '@types/jest': ['tsconfig.json'],
         'ts-graphql-plugin': ['tsconfig.json'],
-        'tsconfig-base': ['tsconfig.build.json'],
+        'tsconfig-base': ['tsconfig.array-extends.json', 'tsconfig.build.json'],
       },
       using: {
         '@mybrand/tsconfig': ['tsconfig.json'],
+        '@tsconfig/recommended': ['tsconfig.array-extends.json'],
         '@types/jest': ['tsconfig.json'],
         '@types/node': ['tsconfig.json'],
         'ts-graphql-plugin': ['tsconfig.json'],
-        'tsconfig-base': ['tsconfig.build.json'],
+        'tsconfig-base': ['tsconfig.array-extends.json', 'tsconfig.build.json'],
         'typescript-eslint-language-service': ['tsconfig.json'],
       },
     },