Microsoft/TypeScript

No duplicate identifier error issued if `const` declared with function type with expandos

Open

#57,985 建立於 2024年3月28日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: BinderHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

🔎 Search Terms

To be updated

🕗 Version & Regression Information

See playground link

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.3#code/JYOwLgpgTgZghgYwgAgCIQM4KsARnXAGxQG8BYAKGWQAoMAuZDMHEAcwEpHcB7H4uCADclagBNMCRs1ZsRFAL6VKAehXJiYZDEbosOfERQBeWgyYtQnZMYB8yFgFcI8hDxDNtuyQYLEbZtKW7Bw29k4uyhRuHvwQAHSEPGw0MPESWBzylGkZCAG5ktQA1MgA5PGVALY8UBBl2dHuGHGJyanpkllRMZ4wAQBMjZraAQDMjQBucFCjpmVjAxCLDZRAA

💻 Code

interface Describable {
  (s: string): boolean;
  desc: string;
}

// let f: Describable = (s: string) => true;
const f: Describable = (s: string) => true;

console.log(f.desc);

f.desc = f.desc  + '...more';

console.log(f.desc);

const f = 2;

let f = 3;

var f = '32e32';

"use strict";
// let f: Describable = (s: string) => true;
const f = (s) => true;
console.log(f.desc);
f.desc = f.desc + '...more';
console.log(f.desc);
const f = 2;
let f = 3;
var f = '32e32';

{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "declaration": true,
    "target": "ES2017",
    "jsx": "react",
    "module": "ESNext",
    "moduleResolution": "node"
  }
}

Playground Link: Provided

🙁 Actual behavior

No errors

🙂 Expected behavior

Errors

Additional information about the issue

Also try with let by commenting line 7 and uncommenting line 6

貢獻者指南