Merge pull request #28451 from koss-lebedev/master

Add typings for react-sound package
This commit is contained in:
Armando Aguirre
2018-08-29 15:45:22 -07:00
committed by GitHub
4 changed files with 94 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for react-sound 1.2
// Project: https://github.com/leoasis/react-sound
// Definitions by: Konstantin Lebedev <https://github.com/koss-lebedev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from "react";
declare namespace ReactSound {
type PlayStatus = 'PLAYING' | 'STOPPED' | 'PAUSED';
interface ReactSoundProps {
url: string;
playStatus: PlayStatus;
playFromPosition?: number;
position?: number;
volume?: number;
playbackRate?: number;
autoLoad?: boolean;
loop?: boolean;
onError?: () => void;
onLoading?: () => void;
onLoad?: () => void;
onPlaying?: () => void;
onPause?: () => void;
onResume?: () => void;
onStop?: () => void;
onFinishedPlaying?: () => void;
onBufferChange?: () => void;
}
}
declare const ReactSound: React.ComponentClass<ReactSound.ReactSoundProps>;
export = ReactSound;
+33
View File
@@ -0,0 +1,33 @@
import ReactSound from "react-sound";
import * as React from "react";
const ReactSoundRequiredOptions: JSX.Element = (
<ReactSound
url="http://test.com"
playStatus="STOPPED"
/>
);
const callbackFn = () => ({});
const ReactSoundAllOptions: JSX.Element = (
<ReactSound
url="http://test.com/audio.mp3"
playStatus="STOPPED"
playFromPosition={0}
position={0}
volume={0}
playbackRate={0}
autoLoad
loop={false}
onError={callbackFn}
onLoading={callbackFn}
onLoad={callbackFn}
onPlaying={callbackFn}
onPause={callbackFn}
onResume={callbackFn}
onStop={callbackFn}
onFinishedPlaying={callbackFn}
onBufferChange={callbackFn}
/>
);
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"esModuleInterop": true
},
"files": [
"index.d.ts",
"react-sound-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }