Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node typescript lacks a construct signature (new Buffer)

Im my node + typescript application I have the following code.

 const base64Data = new Buffer.from(url, 'base64');

Here it gives the following error.

'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.

I have installed @types/node. Why am I getting this error? How can I fix this?

like image 859
Shashika Avatar asked Jan 29 '26 06:01

Shashika


1 Answers

You can fix it by either using

Buffer.from(url, 'base64');

or

new (Buffer.from as any)(url, 'base64');

But, I don't know why this is an issue if you have types installed.

like image 115
Fahad Farooq Avatar answered Jan 31 '26 20:01

Fahad Farooq