From 7b43a570da85cdb1672b0c7f6fb8e329f6ea702e Mon Sep 17 00:00:00 2001 From: sktbcbbs <9651260+sktbcbbs@users.noreply.github.com> Date: Wed, 4 Jul 2018 01:28:29 +0900 Subject: [PATCH] Add Types for react-coinhive (#27010) * Add Types for react-coinhive * Update TypeScript version (#27010) --- types/react-coinhive/index.d.ts | 44 +++++++++++++++++++ types/react-coinhive/react-coinhive-tests.tsx | 23 ++++++++++ types/react-coinhive/tsconfig.json | 24 ++++++++++ types/react-coinhive/tslint.json | 1 + 4 files changed, 92 insertions(+) create mode 100644 types/react-coinhive/index.d.ts create mode 100644 types/react-coinhive/react-coinhive-tests.tsx create mode 100644 types/react-coinhive/tsconfig.json create mode 100644 types/react-coinhive/tslint.json 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" }