Spidy88 / lint-staged-tsc

A simple tool to run tsc against staged files only, ignore errors in other files
MIT License
2 stars 0 forks source link

[Error] TypeError: Cannot read properties of null (reading 'toString') #1

Open irv-armenta-g opened 3 months ago

irv-armenta-g commented 3 months ago

I will try to add kind of the environment I am working on right now: it's a NextJS project using typescript, NextJS is version 12.3.

Typescript: "typescript": "5.4.5"

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2015",
    "baseUrl": ".",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "incremental": false,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "jsx": "preserve",
    "paths": {
      "@components/*": ["src/components/*"],
      "@hooks/*": ["src/hooks/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules", "svgo.config.js"]
}

related packages versions: (not full package.json)

{
    "@spidy88/lint-staged-tsc": "^1.0.0",
    "tsc-files": "^1.1.4",
    "husky": "7.0.2",
    "lint-staged": "^15.2.2",
}

I am using babel at the moment to get code test coverage using istanbul ; .babelrc file in root.

{
  "presets": ["next/babel"],
  "env": {
    "development": {
      "plugins": ["istanbul"]
    }
  }
}

And this is the error:

✖ lint-staged-tsc --noEmit --strict:
xxxxxxxxxxx\node_modules\@spidy88\lint-staged-tsc\cli.js:26
const outputLines = stdout.toString().split(/[\r\n]+/);
                           ^

TypeError: Cannot read properties of null (reading 'toString')
    at Object.<anonymous> (xxxxxxxxxxxxxxxxxxxxx\node_modules\@spidy88\lint-staged-tsc\cli.js:26:28)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.10.0
Spidy88 commented 3 months ago

I'm not able to recreate. No documentation that calls out why stdout would return null for the pipe option. Which platform are you running on? Can you try running tsc-files by itself? I'm curious if that command is failing and causing stdout to return null. Any sort of reproducible minimal environment would be extremely helpful

irv-armenta-g commented 2 months ago

I am running this on windows.

I updated husky and lint-staged to latest version

  "husky": "9.0.11",
  "lint-staged": "15.2.7",

I still keep getting the same error:

yarn run v1.22.21
$ xxx\node_modules\.bin\lint-staged
✔ Preparing lint-staged...
⚠ Running tasks for staged files...
  ❯ .lintstagedrc — 8 files
    ❯ *.{ts,tsx} — 3 files
      ✖ lint-staged-tsc --noEmit --strict [FAILED]
      ◼ biome check --write --no-errors-on-unmatched
    ❯ *.cy.{ts,tsx} — 3 files
      ✖ yarn cy:run --spec [KILLED]
    ↓ *.{js,jsx} — no files
↓ Skipped because of errors from tasks.
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ lint-staged-tsc --noEmit --strict:
xxxl\node_modules\@spidy88\lint-staged-tsc\cli.js:26
const outputLines = stdout.toString().split(/[\r\n]+/);
                           ^

TypeError: Cannot read properties of null (reading 'toString')
    at Object.<anonymous> (xxx\node_modules\@spidy88\lint-staged-tsc\cli.js:26:28)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.10.0

I am not sure what you mean just by running tsc-files by itself? This is a NextJS 13 application.

irv-armenta-g commented 2 months ago

Tried running lint-staged-tsc on a file:


> yarn lint-staged-tsc -- src/components/SimpleAppear/SimpleAppear.cy.tsx
yarn run v1.22.21
\node_modules\.bin\lint-staged-tsc src/components/SimpleAppear/SimpleAppear.cy.tsx
xxx\node_modules\@spidy88\lint-staged-tsc\cli.js:26
const outputLines = stdout.toString().split(/[\r\n]+/);
                           ^

TypeError: Cannot read properties of null (reading 'toString')
    at Object.<anonymous> (C:\Users\Irving\Documents\code\gaudiy\tsukiji-user-panel\node_modules\@spidy88\lint-staged-tsc\cli.js:26:28)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.10.0

Getting the same const outputLines = stdout.toString().split(/[\r\n]+/); error.