You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to overload an existing arrow function in a module, exported as const. It works perfectly fine with overrides for function, class and interface, but failing for arrow function declared as const.
Also tried with:
export interface myVar {
(param: number): number
}
It works, but then the arrow function become unusable because it treats it as interface and it's not callable.
The goal of that message (I assume) is to match runtime behavior where the function declaration acts like var vs the const which never allow overriding:
❯ node
Welcome to Node.js v13.6.0.
Type ".help" for more information.
> function a() {}
undefined
> function a() {}
undefined
> const b = () => {}
undefined
> const b = () => {}
Uncaught SyntaxError: Identifier 'b' has already been declared
I'm trying to overload an existing arrow function in a module, exported as
const
. It works perfectly fine with overrides for function, class and interface, but failing for arrow function declared asconst
.Also tried with:
It works, but then the arrow function become unusable because it treats it as
interface
and it's not callable.TypeScript Version: 3.9.2
Search Terms: const, module augmentation, declaration merging, overload, block-scope variable
Expected behavior:
Allow to override block-scoped variables if it's referring to an arrow function. Just like a
function
.Actual behavior:
Related Issues:
Code
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: