microsoft / microsoft/TypeScript
Extend the tsc --listFiles option to specify an output file for the list
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 Search Terms
listFiles redirect
✅ Viability Checklist
- 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 isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
I would like to be able to separate the output from the listFiles option from the rest of the tsc output (eg. compilation errors). I think the easiest way to do this would be to allow an output file to be specified.
📃 Motivating Example
While integrating typescript scripts into a make build process, I wanted to generate dependency files to facilitate incremental builds. Initially I tried running with the listFiles flag and capturing the output to create the dependency files to include in my makefile, however I quickly ran into the following issues:
- Compilation errors and the file list are both output to stdout
- By default capturing the output of a subshell stops it being output to the console
My initial solution was to run tsc twice, once with --listFiles --noEmit and then again without those options. This resulted in excessive build times as I needed to do this for lots of scripts.
For now I have solved the issue with the following bash script that attempts to extract the compilation output from the listFiles output:
#!/usr/bin/env bash
set -e
INPUT_DIR=$1
DEPS_FILE=$2
SQL_SCRIPT=$INPUT_DIR/sql/test.sql
rm -rf "${INPUT_DIR:?}/"lib
if INPUT_FILES=$(npx tsc --project "$INPUT_DIR"/tsconfig.json --listFiles); then
echo "$SQL_SCRIPT: $(echo "$INPUT_FILES" | sed 's/$/ \\/')" > "$DEPS_FILE"
cd "$INPUT_DIR"/lib
node index.js
else
EXIT_CODE=$?
# the following assumes that all important compilation output contains the text ': error'
echo "$INPUT_FILES" | grep ": error"
exit $EXIT_CODE
fi
However it would be much simpler if I could separate the listFiles output using the tsc command, eg:
#!/usr/bin/env bash
set -e
INPUT_DIR=$1
DEPS_FILE=$2
SQL_SCRIPT=$INPUT_DIR/sql/test.sql
rm -rf "${INPUT_DIR:?}/"lib
npx tsc --project "$INPUT_DIR"/tsconfig.json --listFilesTo $INPUT_DIR/ts/deps
echo "$SQL_SCRIPT: $(sed 's/$/ \\/' $INPUT_DIR/ts/deps)" > "$DEPS_FILE"
cd "$INPUT_DIR"/lib
node index.js
💻 Use Cases
- What do you want to use this for? : I want to simply integrate the listFiles output into a make based build environment
- What shortcomings exist with current approaches? : The listFiles and compilation error outputs are mixed together
- What workarounds are you using in the meantime? : A complicated shell script that tries to extract the compilation output from the listFiles output
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem tsc-Befehl und seiner bestehenden --listFiles-Behandlung, wobei das motivierende Bash-Skript und der tsconfig-Aufruf als Verhaltenskontext dienen. Lege fest, wie eine Ausgabedatei-Option die Dateiliste von Kompilierungsdiagnosen trennen soll, füge dann Abdeckung für erfolgreiche und fehlschlagende Kompilierungen hinzu und überprüfe die erzeugte Abhängigkeitsdatei.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- build-system, cli
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100