Microsoft/TypeScript

Unexpected "used before its declaration" error when implementing a exported type of a merged namespace

Open

#54,429 创建于 2023年5月28日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: BinderHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

Bug Report

🔎 Search Terms

used before its declaration vscode

🕗 Version & Regression Information

  • tested in 4.7.3, 5.0.4 and nightly

⏯ Playground Link

Playground link with relevant code

💻 Code

namespace Foo {
    export interface Bar { }
}

class X implements Foo.Bar {

}

const Foo = 1;

🙁 Actual behavior

In VSCode it reports:

namespace Foo
Block-scoped variable 'Foo' used before its declaration.ts(2448)
Untitled-1(9, 7): 'Foo' is declared here.
Variable 'Foo' is used before being assigned.ts(2454)

You may not see the error immediately if you paste the code into a new file. It will appear when you start typing something.

Note that the error cannot be reproduced in the playground.

🙂 Expected behavior

No error.

贡献者指南