I recently integrated the library react-native-fingerprint-scanner into my React Native project that is running on TypeScript. However, I encountered an issue when trying to call a function from the library.
The project functions perfectly fine in JavaScript:
componentDidMount() {
FingerprintScanner
.isSensorAvailable()
.catch(error => this.setState({ errorMessage: error.message }));
}
But when attempting to call it the same way,
componentDidMount
In the TypeScript project, I receive the following error message:
TypeError: FingerprintScanner.isSensorAvailable is not a function.(In 'FingerprintScanner.isSensorAvailable' is undefined)
Note that I had to import using
const FingerprintScanner = require('react-native-fingerprint-scanner');
As importing with
import { FingerprintScanner } from 'react-native-fingerprint-scanner';
Results in the error:
Could not find a declaration file for module 'react-native-fingerprint-scanner'
Any suggestions on how to make TypeScript recognize this function? Thanks!