microsoft / microsoft/TypeScript

Build mode ignores inherited --pretty flag when run through lerna

Open
#39,178 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: tsc -b
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 39.4

Search Terms: build pretty

"Code"
I am currently in the process of converting a project to a monorepo. Here I noticed that tsc -b seems to ignore the --pretty flag defined in a parent tsconfig when its run through lerna (with the stream flag set to true).
The project is set up as follows
tsconfig.json: pretty => true
tsconfig.build.json: extends from tsconfig.json
package/package-name/tsconfig.build.json: extends from ../../tsconfig.build.json
package/package-name/package.json defines the npm scripts

"scripts": {
  "prebuild": "gulp prebuild",
  "build": "tsc -b tsconfig.build.json",
}

The pretty flag only works sometimes:
If I manually execute npm run build in the package dir, the tsc output is pretty.
If I execute lerna run build --scope=package-name, the tsc output is NOT pretty.
If I execute lerna exec --scope=package-name -- npm run build, the tsc output is pretty.
If I manually add the --pretty flag to the npm script ("tsc -b tsconfig.build.json --watch --pretty"), the tsc output is pretty in all the cases.

Although this might be caused by lerna, I suspect this is actually a bug in TypeScript, because the prebuild output from gulp is colored (pretty) in all the cases I mentioned and manually adding the flag also works.

Expected behavior:
CLI output is "pretty"

Actual behavior:
It is not

Playground Link: not applicable

Related Issues: https://github.com/microsoft/TypeScript/issues/30282

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 by reproducing the three command forms: npm run build in the package directory, lerna run build --scope=package-name, and lerna exec --scope=package-name -- npm run build. Inspect how tsc -b reads the chained tsconfig.json files and handles --pretty when invoked through lerna. Done means the inherited pretty setting produces consistent CLI output, or the issue is shown to belong to lerna instead.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.