add types for react-mic (#40845)

This commit is contained in:
mikaello
2019-12-18 18:47:21 +01:00
committed by Daniel Rosenwasser
parent a4aafc64dd
commit d3197272fc
4 changed files with 79 additions and 0 deletions

35
types/react-mic/index.d.ts vendored Normal file
View File

@@ -0,0 +1,35 @@
// Type definitions for react-mic 12.4
// Project: https://hackingbeauty.github.io/react-mic
// Definitions by: mikaello <https://github.com/mikaello>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as React from 'react';
/**
* Record a user's voice and display as an oscillation (or frequency bars).
*/
export class ReactMic extends React.PureComponent<ReactMicProps> {}
export interface ReactMicProps {
/** Set to true to begin recording */
record?: boolean;
/** Available in React-Mic-Plus upgrade only */
pause?: boolean;
visualSetting?: 'sinewave' | 'frequencyBars';
className?: string;
/** Callback that is executed when audio stops recording */
onStop?: (recordedData: Blob) => void;
/** Callback that is executed when chunk of audio is available */
onData?: (recordedData: Blob) => void;
/** Sound wave color */
strokeColor?: string;
/** Background color */
backgroundColor?: string;
}

View File

@@ -0,0 +1,18 @@
import * as React from 'react';
import { ReactMic } from 'react-mic';
class ReactMicTest extends React.Component {
render() {
return (
<ReactMic
record={true}
className="sound-wave"
onStop={data => console.log(data)}
onData={data => console.log(data)}
strokeColor="#000000"
backgroundColor="#FF4081"
/>
);
}
}

View File

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

View File

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