Microsoft/TypeScript

If a tsc command is not able to run because there is no tsconfig.json file give the user some sort of hint about that

オープン

#50,615 opened on 2022/09/02

 (5 件のコメント) (1 件のリアクション) (0 人の担当者)TypeScript (13,395 件のフォーク)batch import
Experience EnhancementHelp WantedSuggestion

Repository metrics

Stars
 (108,860 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Suggestion

🔍 Search Terms

tsconfig.json

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • [?] This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Here's what I did:

✗ cat package.json | grep type
    "typecheck": "tsc --noEmit",
    "typescript": "~4.8.2",

✗ npx which tsc
/Users/justin.collum2@nutrien.com/work/recommendations-dp/node_modules/.bin/tsc

✗ yarn typecheck

Result: I get the help text, which implies that I used an invalid CLI flag. But the CLI flag I used is in the help text! So it was very confusing.

Then I realized that this is a monorepo and it doesn't have a root tsconfig file:

✗ ls -alh | grep tsconfig

✗

I suspect that's the issue.

If tsc can't proceed because there is no config file that it is able to find, say so. Don't emit the help text, emit an error like "Can't proceed, no config file found, search paths: ..."

Just getting the CLI help text was very misleading.

📃 Motivating Example

💻 Use Cases

コントリビューターガイド