microsoft / microsoft/TypeScript
[ID-Prep] Explicit type annotation of const replaced with initializer in declaration emit
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
The [ID-prep] set of issues aligns Declaration Emit with the forthcoming Isolated Declarations feature.
🔎 Search Terms
declarations type annotation const not preserved
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
enum E { "some value" = 1 };
const e: typeof E["some value"] = E["some value"];
🙁 Actual behavior
e is emitted in declarations as declare const e = E["some value"];
🙂 Expected behavior
e should have in declarations the type that was manually declared
Additional information about the issue
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the declaration emit behavior from the linked Playground using the enum and explicitly typed const shown in the issue. Trace the declaration-emit path for that declaration and verify that the generated declaration preserves the manually written type instead of using the initializer expression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100