microsoft / microsoft/TypeScript

No error when exporting from global augmentations

Offen
#64,152 0 Kommentare 1 Reaktion 2 zugewiesene Personen Auf GitHub ansehen

@DanielRosenwasser arbeitet bereits daran.

Seit 04.9.2026.

  • #64162 von @copilot-swe-agent — offen
Breaking Change Bug
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

If you export a binding from the global scope, you're supposed to get an error unless you create a local binding and export it with whatever name you want.

```ts
export { Math };
// ~~~~
// Cannot export 'Math'. Only local declarations can be exported from a module.
```

However, we have a hole and allow exports that originate from a global augmentation. The following file is permitted with no error:

```ts
declare global {
var XYZ: number;
}

export { XYZ };
```

[Playground Link](https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEBzCB7ARlC8DeAoeB8AbrPABoCaAWgFzwB2ArgLZogwDcuAvrriAA8ADihgAXHOWrxuHIA)

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.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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