microsoft / microsoft/TypeScript

Use absolute file paths in error messages

Offen
#36,221 20 Kommentare 59 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Domain: Error Messages In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

Search Terms

absolute

Suggestion

Output absolute paths in type errors for tsc, or at least a way to specify this.

Use Cases

When type checking in monorepositories, typically tsc is run for each workspace. tsc is then run relative to the workspace it is run from, whereas developers are mostly interested in either the absolute path, or the path relative to the project root.

I have configured my terminal emulator so I can CTRL-click a file and then the file is opened in VSCode, even on the correct line. This works for tsc output in simple TypeScript projects, because the file paths are relative to the project root. This also works for example for ESLint output, because it prints absolute paths. This does not work for tsc in mono repositories, because the output of yarn workspaces run tsc is relative to that workspace.

Examples

Clone and install a TypeScript mono repository.

git clone https://gitlab.com/remcohaszing/koas.git
cd koas
yarn

Let’s open the project using VSCode, since its builtin terminal is preconfigured to work with CTRL-click.

Run yarn workspaces run tsc in the VSCode terminal. This should work fine.

Now mess up any type. I changed an instance of koas.Middleware to koas.Middlewar in packages/koas-core/src/index.ts.

Run yarn workspaces run tsc in the VSCode terminal again. Now this outputs an error and a file path. The file path is not clickable, because it can’t be resolved.

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, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem mit yarn workspaces run tsc und dem Beispielpfad packages/koas-core/src/index.ts. Beginne damit nachzuverfolgen, wie tsc Dateipfade in seinen Diagnosen formatiert; als erledigt gilt die Aufgabe, wenn Diagnosen absolute Pfade erzeugen können oder eine unterstützte Möglichkeit bieten, diese anzufordern, wobei das bestehende Verhalten beibehalten wird, sofern es nicht konfiguriert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
cli, compilers
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.