microsoft / microsoft/TypeScript

No error when exporting from global augmentations

Open
#64,152 0 comments 1 reaction 2 assignees Claimed by @DanielRosenwasser View on GitHub
Breaking Change Bug
Dominant language
Go
Stars
111k
Forks
14.3k
PR merge metrics
PR metrics pending

Description

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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.