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 创建于 2022年9月2日

 (5 条评论) (1 个反应) (0 位负责人)TypeScript (13,395 个派生)batch import
Experience EnhancementHelp WantedSuggestion

仓库指标

星标
 (108,860 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南