Added declaration of JodusNodus/react-qr-reader (#27665)

* Added declaration of JodusNodus/react-qr-reader

* lint fix

* Fix react-qr-reader issues

* Fix delay type and add event param for onImageLoad func
This commit is contained in:
David Kevork
2018-08-01 04:48:12 +10:00
committed by Sheetal Nandi
parent ac91f0945d
commit 25ea12a5d2
4 changed files with 70 additions and 0 deletions

30
types/react-qr-reader/index.d.ts vendored Normal file
View File

@@ -0,0 +1,30 @@
// Type definitions for react-qr-reader 2.1
// Project: https://github.com/JodusNodus/react-qr-reader
// Definitions by: David Kevork <https://github.com/davidkevork>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from "react";
export as namespace QrReader;
export default QrReader;
export namespace QrReader {
interface props {
onScan: (data: string | null) => void;
onError: (err: any) => void;
onLoad?: () => void;
onImageLoad?: (event: React.SyntheticEvent<HTMLImageElement>) => void;
delay?: number | false;
facingMode?: 'user' | 'environment';
legacyMode?: boolean;
resolution?: number;
showViewFinder?: boolean;
style?: any;
className?: string;
}
}
declare class QrReader extends React.Component<QrReader.props> {
}

View File

@@ -0,0 +1,14 @@
import * as React from "react";
import QrReader from "react-qr-reader";
export class Test extends React.Component {
render() {
return (
<QrReader
onError={(err) => { console.log(err); }}
onScan={(data) => { console.log(data); }}
facingMode={'user'}
/>
);
}
}

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-qr-reader-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }