Support for BigInt is not available in TypeScript version 3.5.*

It seems that TypeScript has supported BigInt since version 3.2, and my project is using TypeScript 3.5. Despite not explicitly declaring any variables as BigInt, I recently integrated a package called BufferUtility from https://github.com/Pharuxtan/BufferUtility#readme.

However, upon adding this package, my project encountered a compilation error:

node_modules/bufferutility/index.d.ts(37,37): error TS2304: Cannot find name 'BigInt'.

This issue took me by surprise, as my research indicated that it could be a problem for those on TypeScript versions older than 3.2. Am I overlooking something here?

Answer №1

Summary:

  1. bigint becomes a valid type in Typescript 3.2.
  2. BigInt is recognized as a type starting in Typescript 3.9.
  3. The bufferutility module employs BigInt within its types.

Conclusion: To utilize bufferutility, you need Typescript version 3.9 or higher.


I couldn't locate the release notes, but it appears that BigInt isn't usable as a type in versions below 3.8.

Check 3.8.3 playground

However, from version 3.9 onwards, it functions as intended.

Explore 3.9.7 Playground

It seems that the typings for BufferUtility rely on BigInt as a type, suggesting a minimum requirement of Typescript 3.9 for compatibility.


Interesting facts about these data types:

declare let a: bigint
declare let b: BigInt

b = a // works fine, bigint can be assigned to BigInt
a = b // Error. Type 'BigInt' is not assignable to type 'bigint'.(2322)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The plugin 'react' could not be loaded as it was declared in 'package.json', specifically in 'eslint-config-react-app'. The error encountered was an unexpected end of input

After successfully creating a React project, everything was running smoothly until an error popped up stating: Failed to load plugin 'react' declared in 'package.json » eslint-config-react-app » D:\Dev\fegig\omega\trade ...

How to Show Concealed Text in Material UI Multiline TextField and Obtain Unveiled Text

I am currently using the Material UI TextField component to create a multiline input for messages. My aim is to display a masked version of the text in the GUI while retaining the unmasked text value for processing purposes. Below is the code snippet for ...

What causes the variable to be undefined in the method but not in the constructor in Typescript?

I am currently working on an application using AngularJS 1.4.9 with Typescript. In one of my controllers, I have injected the testManagementService service. The issue I'm facing is that while the testManagementService variable is defined as an object ...

Encountering a syntax error when running newman on an Ubuntu system

Just starting out with newman and looking to integrate it into my CI\CD pipeline (specifically VSTS). I've been able to export my collection.json and env.json files, but running the tests is giving me some trouble. newman run Dev-.postman_collect ...

How can we define a function using a generic type in this scenario using Typescript?

Here's a challenge that I'm facing. I have this specific type definition: type FuncType<T> = (value: T) => T I want to create a function using this type that follows this structure: const myFunc: FuncType<T> = (value) => valu ...

Unable to complete npm installation because of node-gyp: binding.gyp file missing

This has been consuming my entire day and I've experimented with various solutions: Uninstalled node and installed the latest version Used the --msvs_version= flag set to 2010, 2011, 2012, 2013, 2015 Deleted the .node-gyp folder Added python path to ...

Using Vuetify to filter items in a v-data-table upon clicking a button

My table structure is similar to this, I am looking to implement a functionality where clicking on the Filter Button will filter out all items that are both male and valid with a value of true. users = [ { name: 'ali', male: true, valid: ...

I am looking to transfer 'beforeEach' and 'afterEach' from the spec file to the global configuration file in WDIO [mocha, hook, wdio]

My E2E testing setup involves using the WebdriverIO library along with the mocha framework. During test execution, I want Mocha to automatically skip all subsequent checks in a test after encountering the first error, and proceed to the next test file. T ...

What is the proper way to specify the type for the iterable response of Promise.all()?

It's common knowledge that Promise.all will return settled promises in the same order of the requested iterable. I'm currently grappling with how to correctly define types for individual settled resolves. I am utilizing Axios for handling asynch ...

Utilizing Node.js, Express, Jade, and Templates within a single package

Can templates for an express application be stored in a separate package? In my scenario, I am interested in having a shared package that contains global templates to ensure all apps have a consistent look and feel, even if they are running independently ...

Installing a local package with npm creates symbolic links

I recently created a unique node.js package on my local system and successfully installed it using npm in another project. However, after attempting to push it to a remote git repository or web server, the package is not being recognized by my application. ...

The type 'typeof globalThis' does not have an index signature, therefore the element is implicitly of type 'any'. Error code: ts(7017) in TypeScript

I'm encountering an issue with my input handleChange function. Specifically, I am receiving the following error message: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.ts(7017) when att ...

Converting HTML into an image in a Node.js Buffer

Can you suggest a simple method to convert a raw HTML string, like the following: <b>Hello World</b> into a regular PNG image in Node.js Buffer form? I've been exploring various npm packages for a solution that supports this functionali ...

The function of `npm list -g` is disabled if Nodejs is installed using nvm

After reinstalling Nodejs and npm using nvm, everything seemed to be working fine except for the npm list -g command. When I ran the command, it only displayed npm as the global package: https://i.stack.imgur.com/PKT1y.png However, I have actually instal ...

What are the steps to launching an Electron application with arguments?

I have developed an electron app using a BrowserWindow to load a local page index.html. By running the script npm run start, which executes electron main.js, the app launches and loads the html file successfully. Is there a way to modify the script to ...

How can you optimize the storage of keys in JS objects?

Just pondering over this scenario: Consider a line definition like the one below, where start and end are both points. let ln = { s: {x:0, y:0}, e: {x:0, y:0}, o: 'vertical' } Now imagine having a vast array of lines, how can we sav ...

Exploring the capabilities of SWR for updating data in Next JS

I have been working on creating a component with an active property that can be toggled by the user as many times as they want. Since I am using Next.js, I decided to implement SWR for client-side rendering. However, despite my efforts over the past few da ...

Discover corresponding NPM module

I'm dealing with a strange problem. I created a Node package for local use and used NPM link to make it accessible globally through the command line. But now, I want to update the package and can't seem to find its location on my drive, even th ...

Encountering a npm installation issue

When attempting to run npm install, I encountered the following error. Can someone provide insight into the possible problem and a solution? npm ERR! network tunneling socket could not be established, cause=connect ECONNREFUSED npm ERR! network This is ...

Re-posting a package that already exists leads to an Invalid Semantic Version error

My goal is to republish the package mssql version 10.0.0 as mssql-10 in order to have both versions coexist for incremental migration purposes over a prolonged period. After making changes only to the 'name' and 'description' attribute ...