JoshuaKGoldberg / TypeStat

Converts JavaScript to TypeScript and TypeScript to better TypeScript. 🧫
MIT License
2.06k stars 39 forks source link

extends tsconfig.json can't resolve @tsconfig/ package #1306

Open gutenye opened 1 year ago

gutenye commented 1 year ago

🐛 Bug Report

Actual Behavior

Error: ENOENT: no such file or directory, stat 'node_modules/@tsconfig/node16/tsconfig.json/package.json'

The correct file should be node_modules/@tsconfig/node16/tsconfig.json

A temporary fix is updating the tsconfig.json with ./node_modules/@tsconfig/node16/tsconfig.json

Expected Behavior

Run without an error

Reproduction

vi tsconfig.json
{
  "extends": "@tsconfig/node16/tsconfig.json",
  "include": [
    "src/**/*"
  ]
}

npx typestat
npx typestat --config typestat.json
// typestat.json
{
    "files": {
        "renameExtensions": false
    },
    "fixes": {
        "incompleteTypes": true,
        "missingProperties": true,
        "noImplicitAny": true
    },
    "cleanups": {
        "suppressTypeErrors": true
    },
    "include": [
        "src/**/*.{js,jsx}"
    ],
    "project": "./tsconfig.json"
}
JoshuaKGoldberg commented 1 year ago

Hey thanks for trying out TypeStat and filing an issue! I can't reproduce locally with those two files though. Is there a standalone gist, repo, or other set-of-code-files you can share that does demonstrate the issue?

gutenye commented 1 year ago

try this tsconfig.json

{
  "extends": "@tsconfig/node16/tsconfig.json",
  "include": [
    "src/**/*"
  ]
}
JoshuaKGoldberg commented 1 year ago

That did it, thanks!

JoshuaKGoldberg commented 1 year ago

A more full stack locally:

Error: ENOTDIR: not a directory, stat '/Users/josh/repos/typestattemp/node_modules/@tsconfig/node16/tsconfig.json/package.json'
    at Object.statSync (node:fs:1620:3)
    at Object.<anonymous> (/Users/josh/repos/TypeStat/node_modules/graceful-fs/polyfills.js:319:16)
    at Object.fileExists (/Users/josh/repos/TypeStat/src/options/parseRawCompilerOptions.js:52:42)
    at getPackageJsonInfo (/Users/josh/repos/TypeStat/node_modules/typescript/lib/typescript.js:40354:33)
    at loadModuleFromSpecificNodeModulesDirectory (/Users/josh/repos/TypeStat/node_modules/typescript/lib/typescript.js:40997:23)
    at loadModuleFromImmediateNodeModulesDirectory (/Users/josh/repos/TypeStat/node_modules/typescript/lib/typescript.js:40974:29)
    at /Users/josh/repos/TypeStat/node_modules/typescript/lib/typescript.js:40962:33
    at forEachAncestorDirectory (/Users/josh/repos/TypeStat/node_modules/typescript/lib/typescript.js:6971:22)
    at lookup (/Users/josh/repos/TypeStat/node_modules/typescript/lib/typescript.js:40956:14)
    at loadModuleFromNearestNodeModulesDirectoryWorker (/Users/josh/repos/TypeStat/node_modules/typescript/lib/typescript.js:40953:14)
josh ~/repos/typestattemp $