diff --git a/types/react-coinhive/index.d.ts b/types/react-coinhive/index.d.ts new file mode 100644 index 0000000000..e266db590b --- /dev/null +++ b/types/react-coinhive/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for react-coinhive 1.0 +// Project: https://github.com/dragma/react-coinhive +// Definitions by: sktbcbbs +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export interface CoinHiveProps { + autoThreads?: boolean; + + run?: boolean; + + siteKey: string; + + src?: string; + + threads?: number; + + throttle?: number; + + userName?: string; + + onInit?: (callback: any) => void; + + onStart?: (callback: any) => void; + + onStop?: (callback: any) => void; +} + +export default class CoinHive extends React.Component { + static getMinerData(miner: any): any; + + static src: { + authedmine: string; + coinhive: string; + }; + + onInit(miner: any): any; + + onStart(miner: any): any; + + onStop(miner: any): any; +} diff --git a/types/react-coinhive/react-coinhive-tests.tsx b/types/react-coinhive/react-coinhive-tests.tsx new file mode 100644 index 0000000000..c108c7cddb --- /dev/null +++ b/types/react-coinhive/react-coinhive-tests.tsx @@ -0,0 +1,23 @@ +import * as React from "react"; +import CoinHive, { CoinHiveProps } from "react-coinhive"; + +export class CoinHiveTest extends React.Component { + render() { + const props: CoinHiveProps = { + userName: "Maya", + siteKey: "tbzWvRTBa3VAKefxUmDZx6P6wjCSHXz0", + autoThreads: false, + threads: 2, + src: CoinHive.src.authedmine, + onInit: () => {}, + onStart: () => {}, + onStop: () => {}, + }; + + return ( +
+ +
+ ); + } +} diff --git a/types/react-coinhive/tsconfig.json b/types/react-coinhive/tsconfig.json new file mode 100644 index 0000000000..bd9fbfee80 --- /dev/null +++ b/types/react-coinhive/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-coinhive-tests.tsx" + ] +} diff --git a/types/react-coinhive/tslint.json b/types/react-coinhive/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-coinhive/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }