Add typings for react-sticky-box package (#29534)

This commit is contained in:
Konstantin
2018-10-08 17:55:13 +02:00
committed by Andy
parent d63c0ae3bc
commit 02177ef013
4 changed files with 68 additions and 0 deletions

22
types/react-sticky-box/index.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
// Type definitions for react-sticky-box 0.7
// Project: https://github.com/codecks-io/react-sticky-box
// 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 ReactStickyBox {
type StickyBoxMode = 'relative' | 'stickyBottom' | 'stickyTop';
interface StickyBoxProps {
bottom?: boolean;
offsetTop?: number;
offsetBottom?: number;
onChangeMode?: (oldMode: StickyBoxMode, newMode: StickyBoxMode) => void;
}
}
declare const ReactStickyBox: React.ComponentClass<ReactStickyBox.StickyBoxProps>;
export = ReactStickyBox;

View File

@@ -0,0 +1,19 @@
import ReactStickyBox, { StickyBoxMode } from "react-sticky-box";
import * as React from "react";
const ReactStickyBoxRequiredOptions: JSX.Element = (
<ReactStickyBox />
);
const changeHandler = (oldMode: StickyBoxMode, newMode: StickyBoxMode) => {
console.log(`Changing from ${oldMode} to ${newMode}`);
};
const ReactStickyBoxAllOptions: JSX.Element = (
<ReactStickyBox
bottom
offsetBottom={20}
offsetTop={10}
onChangeMode={changeHandler}
/>
);

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-sticky-box-tests.tsx"
]
}

View File

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