mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for react-countup (#29730)
* Add types for react-countup * Update ts config * Update types * Add additional props
This commit is contained in:
parent
03dadc776c
commit
9a785a5926
65
types/react-countup/index.d.ts
vendored
Normal file
65
types/react-countup/index.d.ts
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
// Type definitions for react-countup 4.0
|
||||
// Project: https://react-countup.now.sh
|
||||
// Definitions by: Daniel Brodin <https://github.com/danielbrodin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
export as namespace ReactCountUp;
|
||||
|
||||
export = ReactCountUp;
|
||||
|
||||
declare namespace ReactCountUp {
|
||||
interface RenderProps {
|
||||
countUpRef: React.RefObject<any>;
|
||||
pauseResume(): void;
|
||||
reset(): void;
|
||||
start(): void;
|
||||
update(newEnd?: number): void;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
decimal?: string;
|
||||
decimals?: number;
|
||||
delay?: number;
|
||||
duration?: number;
|
||||
end?: number;
|
||||
prefix?: string;
|
||||
redraw?: boolean;
|
||||
separator?: string;
|
||||
start?: number;
|
||||
suffix?: string;
|
||||
useEasing?: boolean;
|
||||
easingFn?(t: number, b: number, c: number, d: number): void;
|
||||
formattingFn?(value: number): string;
|
||||
onComplete?(): void;
|
||||
onEnd?(providedFn: {
|
||||
pauseResume(): void;
|
||||
reset(): void;
|
||||
start(): void;
|
||||
update(): void;
|
||||
}): void;
|
||||
onStart?(providedFn: {
|
||||
pauseResume(): void;
|
||||
reset(): void;
|
||||
update(): void;
|
||||
}): void;
|
||||
onPauseResume?(): (
|
||||
providedFn: { reset(): void; start(): void; update(): void }
|
||||
) => void;
|
||||
onReset?(): (
|
||||
providedFn: { pauseResume(): void; start(): void; update(): void }
|
||||
) => void;
|
||||
onUpdate?(providedFn: {
|
||||
pauseResume(): void;
|
||||
reset(): void;
|
||||
start(): void;
|
||||
}): void;
|
||||
style?: React.CSSProperties;
|
||||
children?(data: RenderProps): React.ReactElement<any>;
|
||||
}
|
||||
}
|
||||
|
||||
declare class ReactCountUp extends React.PureComponent<ReactCountUp.Props> {}
|
||||
17
types/react-countup/react-countup-tests.tsx
Normal file
17
types/react-countup/react-countup-tests.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
import * as React from "react";
|
||||
import * as CountUp from "react-countup";
|
||||
|
||||
export class Test extends React.Component<any> {
|
||||
render() {
|
||||
return (
|
||||
<CountUp start={0} end={100}>
|
||||
{({ countUpRef, start }) => (
|
||||
<div>
|
||||
<span ref={countUpRef} />
|
||||
<button onClick={start}>Start</button>
|
||||
</div>
|
||||
)}
|
||||
</CountUp>
|
||||
);
|
||||
}
|
||||
}
|
||||
25
types/react-countup/tsconfig.json
Normal file
25
types/react-countup/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"jsx": "react",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-countup-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-countup/tslint.json
Normal file
1
types/react-countup/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user