Skip to content

Latest commit

 

History

History
39 lines (34 loc) · 1.25 KB

typescript_support.md

File metadata and controls

39 lines (34 loc) · 1.25 KB

TypeScript support

FingerprintJS has built-in TypeScript types. In order to use them, just install the library and import it in a .ts file:

npm i @fingerprintjs/fingerprintjs
# or
yarn add @fingerprintjs/fingerprintjs
import FingerprintJS from '@fingerprintjs/fingerprintjs'

FingerprintJS officially supports TypeScript version 4.9, but may work with newer and older versions of TypeScript. If you face a TypeScript error that occurs in a .d.ts file provided by FingerprintJS (example 1, example 2), consider any of these solutions:

  • Update the TypeScript package in your project to version 4.9 or newer
    npm i typescript@^4.9
    # or
    yarn add typescript@^4.9
  • Prevent TypeScript from using the library types. To do it, replace
    import ... from '@fingerprintjs/fingerprintjs'
    with
    import ... from '@fingerprintjs/fingerprintjs/dist/fp.esm'
    in your .ts files, and add the following line to a .d.ts file (if there is no such file, create one anywhere with any name):
    declare module '@fingerprintjs/fingerprintjs/dist/fp.esm'