Microsoft/TypeScript

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

Open

#58.456 aberto em 7 de mai. de 2024

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (6.726 forks)batch import
BugDomain: Declaration EmitHelp Wanted

Métricas do repositório

Stars
 (48.455 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)

Description

🔎 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

Guia do colaborador