user310291
user310291

Reputation: 38180

How to redefine type for an existing function in Typescript

Solution here https://www.albertgao.xyz/2016/08/11/how-to-declare-a-function-type-variable-in-typescript/ requires to define an expression, that's not what I want. What I want is to declare existing function as any something like this except syntax is not valid:

function f() {} as any;
f.someProperty = "I want to do this without squizzle in vscode";

goal is to avoid squizzle in VScode.

Upvotes: -1

Views: 512

Answers (1)

starball
starball

Reputation: 50064

Does this work for you?

const f = function () {} as any;
f.someProperty;

From the comments by the asker:

I wanted to avoid function expression but seems I have to because const f doesn't hoist.

Upvotes: 1

Related Questions