microsoft / microsoft/TypeScript

When using a string value as export for reference, the .d.ts file created with dot notation instead of computed property which can break

Đang mở
#61,159 0 bình luận 1 reaction 1 người được giao Được @rbuckton nhận Xem trên GitHub
Bug Domain: Declaration Emit
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

### 🔎 Search Terms

references, string exports

### 🕗 Version & Regression Information

- This changed between versions 5.6 and 5.7.3
- ~~This changed in commit or PR _______~~. It's a feature wasn't implemented fully
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about: Yes
- I was unable to test this on prior versions because: It's a new feature that isn't fully implemented (string exports)

### ⏯ Playground Link

https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgGIHt3IN4F8BQ+EAHgA7pRg5qbJwDOyARAH4bpPIH4D0PyAC3QB3ZABMsAV2TCowSMnkB+ZCHRhgSZGAFwqAAzaZ9ixnElh0AWgToAtqQA2EMHABGzwdAi9+wgZoCpnSO9FhqVLZQUBAIVADmwABuECCKYADkjBHI8eggIHDIbihJcI7AYnQwkFDItg7OGvn4YACepCgAKhD0VAC8ig4UYAAUGQB0PKCkFhkAlBNG6EA

### 💻 Code

A [demo repo](https://github.com/oriSomething/ts-references-bug)

```ts
// In a project with references that I forced to export a "private export". I export it as a string value which breaks .d.ts creation
interface ReferenceTo {
(value: T): T;
value: T;
}

// The `as "…"` part
export { ReferenceTo as "~ ReferenceTo" };
```

### 🙁 Actual behavior

I get the error

```
a/out/lib/y.d.ts:1:39 - error TS1110: Type expected.

1 export declare const x: import("./x").~ ReferenceTo<"x">;
~

a/out/lib/y.d.ts:1:39 - error TS1110: Type expected.

1 export declare const x: import("./x").~ ReferenceTo<"x">;
~

Found 2 errors.
```

According to @Andarist it somes to the issue as described in the [playground](https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgGIHt3IN4F8BQ+EAHgA7pRg5qbJwDOyARAH4bpPIH4D0PyAC3QB3ZABMsAV2TCowSMnkB+ZCHRhgSZGAFwqAAzaZ9ixnElh0AWgToAtqQA2EMHABGzwdAi9+wgZoCpnSO9FhqVLZQUBAIVADmwABuECCKYADkjBHI8eggIHDIbihJcI7AYnQwkFDItg7OGvn4YACepCgAKhD0VAC8ig4UYAAUGQB0PKCkFhkAlBNG6EA)

More in the Bluesky thread: https://bsky.app/profile/andarist.bsky.social/post/3lhrod2ysps2k

### 🙂 Expected behavior

It will export it as a computed value so it work

```ts
export declare const x: import("./x")["~ ReferenceTo"]<"x">;
```

### Additional information about the issue

More in the Bluesky thread: https://bsky.app/profile/andarist.bsky.social/post/3lhrod2ysps2k

It seems it happens with Autocomplete as well.

A [demo repo](https://github.com/oriSomething/ts-references-bug)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.