microsoft / microsoft/TypeScript

`export import` of types is not allowed in namespaces when using `erasableSyntaxOnly`

Open
#61,326 6 comments 0 reactions 0 assignees View on GitHub
Awaiting More Feedback Has Repro Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

export import alias type-only namespaces erasableSyntaxOnly

### 🕗 Version & Regression Information

- I was unable to test this on prior versions because `erasableSyntaxOnly` was just released

### ⏯ Playground Link

https://www.typescriptlang.org/play/?erasableSyntaxOnly=true&ts=5.8.2#code/PTAEBcAsEsGdQO4HsBOBrWBYAUAOwIYC2AprAA74DGxEAnmaaAN46ijEAeZq4oAJsUoAbfChrh6NAGJIkbALygAjDgC+OHCFAAjAK68ocfklK4A5L2ToANKHxCoSXQHNIoaODPwJDALRJcIVpbcFkcAhJyKnFJWAB1D0gAJWJObhReFmw2NJ53QnTeABVQRR9GNQ1sLUN4IyQ0fFpwolIKalAAN3tdRiycrjzKANheADNZUuVK7Bxyuyny2AA6GSQ5yVAORdiEqBTcjOWi1dkgA

### 💻 Code

```ts
// this works
namespace types {
export declare type Foo = 1
}

// but this doesn't work, although it's type-only, too
namespace typesWithReexport {
export import T = types
}

// ignoring the error, generally these should be both accessible
type a = types.Foo
type x = typesWithReexport.T.Foo
```

### 🙁 Actual behavior

`export import` re-exporting a namespace (or namespace member) of a type-only namespace from another type-only namespace results in `This syntax is not allowed when 'erasableSyntaxOnly' is enabled.`

### 🙂 Expected behavior

It should not error.

### Additional information about the issue

@jakebailey asked me to open an issue to track this on bsky: https://bsky.app/profile/jakebailey.dev/post/3ljdc3ou7oc2w

Contributor guide

Open the contributing guide

Research direction

Start with the linked TypeScript Playground reproduction using erasableSyntaxOnly and compare the accepted `export declare type` namespace with the rejected `export import` re-export. Trace the compiler diagnostic for the namespace example and identify the relevant erasable-syntax check. Done means the example no longer reports the error while preserving the expected type-only namespace access.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.