Microsoft/TypeScript

Type printing does not detect that a name is shadowed in the current scope

Open

#58,456 创建于 2024年5月7日

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

仓库指标

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

描述

🔎 Search Terms

global shadowed declarations

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed

⏯ Playground Link

Playground Link

💻 Code

// @strict: true
// @declaration: true
// @target: es2020

// @filename: a.ts
export const o = {[Symbol.iterator]: 1}

// @filename: b.ts

import { o } from "./a";
export class Symbol { }
export const g = o;

🙁 Actual behavior

The typeof of g is { [Symbol.iterator]: number; }. This leads to an incorrect declaration since Symbol is shadowed in the current scope

🙂 Expected behavior

The typeof of g is { [globalThis.Symbol.iterator]: number; }.

Additional information about the issue

No response

贡献者指南