Type definitions for react-custom-scroll (#45628)

* Type definitions for react-custom-scroll

* fix tests
This commit is contained in:
Guy Romm 2020-06-23 21:22:28 +03:00 committed by GitHub
parent b90d8ec168
commit 6df6e314df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 0 deletions

31
types/react-custom-scroll/index.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
// Type definitions for react-custom-scroll 4.2
// Project: https://github.com/rommguy/react-custom-scroll
// Definitions by: Guy Romm <https://github.com/rommguy>
// rvdende <https://github.com/rvdende>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5
import { ComponentClass } from 'react';
/**
* Props for a CustomScroll component.
*/
export interface CustomScrollProps {
allowOuterScroll?: boolean;
heightRelativeToParent?: string;
flex?: number | string;
onScoll?: (e?: any) => any;
addScrolledClass?: boolean;
freezePosition?: boolean;
minScrollHandleHeight?: number;
rtl?: boolean;
scrollTo?: number;
keepAtBottom?: boolean;
}
/**
* Customize scrollbar design while using native scroll behavior.
*/
declare const CustomScroll: ComponentClass<CustomScrollProps>;
export default CustomScroll;

View File

@ -0,0 +1,29 @@
import * as React from 'react';
import CustomScroll from 'react-custom-scroll';
const onScrollStub = () => 1;
export const _ = () => (
<>
<CustomScroll>
<div>Test content</div>
<div>Test content</div>
</CustomScroll>
,
<CustomScroll
heightRelativeToParent="50%"
allowOuterScroll={false}
flex={2}
onScoll={onScrollStub}
addScrolledClass={true}
freezePosition={false}
minScrollHandleHeight={50}
rtl={false}
scrollTo={20}
keepAtBottom={false}
>
<div>Test content</div>
<div>Test content</div>
</CustomScroll>
,
</>
);

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"jsx": "react",
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-custom-scroll-tests.tsx"
]
}

View File

@ -0,0 +1,5 @@
{"extends": "dtslint/dt.json",
"rules": {
"npm-naming": [true,{"mode":"code","errors":[["NoDefaultExport",false]]}]
}
}