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

Open

#50,615 创建于 2022年9月2日

在 GitHub 查看
 (5 评论) (1 反应) (0 负责人)TypeScript (6,726 fork)batch import
Experience EnhancementHelp WantedSuggestion

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 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

贡献者指南