microsoft / microsoft/TypeScript

Extend the tsc --listFiles option to specify an output file for the list

Aperta
#60,966 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔍 Search Terms

listFiles redirect

✅ Viability Checklist
⭐ 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:

  1. Compilation errors and the file list are both output to stdout
  2. 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
  1. What do you want to use this for? : I want to simply integrate the listFiles output into a make based build environment
  2. What shortcomings exist with current approaches? : The listFiles and compilation error outputs are mixed together
  3. What workarounds are you using in the meantime? : A complicated shell script that tries to extract the compilation output from the listFiles output

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il comando tsc e la gestione esistente di --listFiles, usando lo script bash motivante e l’invocazione di tsconfig come contesto comportamentale. Definisci come un’opzione per il file di output debba separare l’elenco dei file dai diagnostici di compilazione, quindi aggiungi la copertura per le compilazioni riuscite e fallite e verifica il file delle dipendenze generato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
build-system, cli
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.