microsoft / microsoft/TypeScript

Enum redeclared as var inside block scope

Open
#30,585 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

TypeScript Version: TS Playground as of 2019-03-25

Search Terms: enum declarations can only merge, enum block scope, enum redeclaration

Code

{ enum Foo { } var Foo }

enum Bar { } var Bar;

Expected behavior:
They should both error, or they should be both accepted

Actual behavior:
Only Bar is an error

Playground Link:
https://www.typescriptlang.org/play/index.html#src=%7B%20enum%20Foo%20%7B%20%7D%20var%20Foo%20%7D%0A%0Aenum%20Bar%20%7B%20%7D%20var%20Bar%3B%0A%0A(function%20()%20%7B%20enum%20Baz%20%7B%20%7D%20var%20Baz%20%7D)

Related Issues:
Found while fixing https://github.com/babel/babel/issues/9763

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.

Research direction

Reproduce the two enum-and-var examples in the linked TypeScript Playground and compare the block-scoped case with the top-level case. Trace the compiler's declaration checks for these snippets and determine the consistent behavior expected for both; done means the two cases agree and the reported regression is covered by an appropriate compiler test.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.