microsoft / microsoft/TypeScript

Allow for dropping tsconfig.json in arbitrary folder and specifying the source root with tsc command

Open
#27,386 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Search Terms

  1. tsconfig.json
  2. TS18003
  3. project root

Suggestion

I have been deving an automation publish tool, with typescript inside. Nice work for you!

Since the tsconfig.json file need to be put in a center config folder other than project/source code root. amd i have tried to use tsc --watch --project path-to-tsconfig.json to make this future, which is not working for now.

I got TS18003 error, and i know why this happen: tsc just want to remind us we may have a wrong include or exclude config. 😄 I cannot find any tsc command should i use to conject with --project option to specify the project root.

I find in the tsc sourcecode that the compiler.parseJsonConfigFileContent(_, _, basePath); function could let us specify the project basePath when parsing tsconfig.json, so, i want to ask if we can expose a command option to let use the same function as basePath, maybe --configFileBasePath or --configContext?

Please let me know if there already is a solution for my use case.

Thank you for your works!

Examples

tsc --project path-to-tsconfig.json --configContext path-to-source-code-root

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. new expression-level syntax)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the tsc --project handling and the compiler.parseJsonConfigFileContent call mentioned in the issue. Trace how tsconfig.json paths determine the project base path and how TS18003 is produced. Done means a documented command option can specify a separate source root for a config in an arbitrary folder, with tests covering the example invocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.