microsoft / microsoft/TypeScript

Computed property name is not escaped in declaration emit

Open
#60,819 0 comments 0 reactions 1 assignee View on GitHub

@weswigham is already working on this.

Since Jan 2, 2025.

Bug Domain: Declaration Emit
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

🔎 Search Terms

computed property symbol declaration emit

🕗 Version & Regression Information
  • This changed between versions 3.7 and 3.8
⏯ Playground Link

https://www.typescriptlang.org/play/?ts=3.7.5#code/MYGwhgzhAEAq0G8BQ1XQgFzBglsaATgKZgAmA9gHYgCe0A2gEQA6GjAugFzQCulOARx5F0NALYAjciADcSAL5IQRDNAAe0ALyIUaerCasOXaAEYFMoA

💻 Code
class T {
    static readonly ["\t"]: unique symbol;
}
let x = {
    [T["\t"]]: 1
};
🙁 Actual behavior

The type of x is emitted as { [T["\t"]]: number; } in declaration files, making the file invalid since the property does not exist on T

🙂 Expected behavior

The escape should be preserved in the property name.

Additional information about the issue

Was introduced by https://github.com/microsoft/TypeScript/pull/18860/commits/8bb7230729f43f1c134f895a535e73c4cd58af3e

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.