Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI v1.1.0+ doesn't read tsconfig.json when --project is not specified #102

Closed
heguro opened this issue Dec 16, 2024 · 2 comments · Fixed by #105
Closed

CLI v1.1.0+ doesn't read tsconfig.json when --project is not specified #102

heguro opened this issue Dec 16, 2024 · 2 comments · Fixed by #105
Labels
bug Something isn't working

Comments

@heguro
Copy link
Contributor

heguro commented Dec 16, 2024

Current behavior

Initialize my repository for reproduce:

$ git clone https://github.com/heguro/20241216-tsr-test
$ cd 20241216-tsr-test
$ npm i

When running tsr without --project: Incorrect output, doesn't read tsconfig.json

$ npx tsr 'main\.ts$'
tsconfig using default options
Project has 3 files. Found 1 entrypoint file
file   src/app/app.ts
file   src/fn/util.ts
✖ delete 2 files

When running tsr with --project: Correct output

$ npx tsr -p tsconfig.json 'main\.ts$'
tsconfig tsconfig.json
Project has 3 files. Found 1 entrypoint file
export src/fn/util.ts:4:0     'unusedFunc'
✖ remove 1 export

Root Cause

  • In the new CLI implementation released in v1.1.0, --project's default value is '', not undefined or 'tsconfig.json'.
    • tsr/lib/cli.ts

      Lines 8 to 15 in 83a7f3b

      {
      name: 'project',
      alias: 'p',
      type: 'string',
      param: '<file>',
      description: 'Path to your tsconfig.json',
      default: '',
      },
  • While 'tsconfig.json' is set as the default value for the configFile parameter in the tsr function, it is not used when '' is passed.
  • This generates an incorrect configPath, causing ts.readConfigFile() to fail.
@kazushisan
Copy link
Contributor

@heguro thank you very much for the detailed report! I've fixed this issue in https://github.com/line/tsr/releases/tag/v1.3.1

@kazushisan
Copy link
Contributor

added test cases to prevent future degrade in #107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants