diff --git a/types/react-virtualized-auto-sizer/index.d.ts b/types/react-virtualized-auto-sizer/index.d.ts new file mode 100644 index 0000000000..29d2ff7da4 --- /dev/null +++ b/types/react-virtualized-auto-sizer/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for react-virtualized-auto-sizer 1.0 +// Project: https://github.com/bvaughn/react-virtualized-auto-sizer/ +// Definitions by: Hidemi Yukita +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from "react"; + +export interface Size { + height: number; + width: number; +} + +export interface AutoSizerProps { + /** Function responsible for rendering children. */ + children: (size: Size) => React.ReactNode; + + /** Optional custom CSS class name to attach to root AutoSizer element. */ + className?: string; + + /** Default height to use for initial render; useful for SSR */ + defaultHeight?: number; + + /** Default width to use for initial render; useful for SSR */ + defaultWidth?: number; + + /** Disable dynamic :height property */ + disableHeight?: boolean; + + /** Disable dynamic :width property */ + disableWidth?: boolean; + + /** Nonce of the inlined stylesheet for Content Security Policy */ + nonce?: string; + + /** Callback to be invoked on-resize */ + onResize?: (size: Size) => void; + + /** Optional inline style */ + style?: React.CSSProperties; +} + +export default class extends React.Component {} diff --git a/types/react-virtualized-auto-sizer/react-virtualized-auto-sizer-tests.tsx b/types/react-virtualized-auto-sizer/react-virtualized-auto-sizer-tests.tsx new file mode 100644 index 0000000000..b194611356 --- /dev/null +++ b/types/react-virtualized-auto-sizer/react-virtualized-auto-sizer-tests.tsx @@ -0,0 +1,51 @@ +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; +import AutoSizer, { Size } from 'react-virtualized-auto-sizer'; + +class TestAutoSizer extends AutoSizer {} + +class TestApp extends React.Component { + onResize = (size: Size) => { + console.log(`width: ${size.width}`); + console.log(`height: ${size.height}`); + } + + render() { + return ( + <> + + {({ width, height }) => { + const _width: number = width; + const _height: number = height; + console.log(`width: ${_width}`); + console.log(`height: ${_height}`); + return null; + }} + + + {({ width, height }) => { + const _width: number = width; + const _height: number = height; + console.log(`width: ${_width}`); + console.log(`height: ${_height}`); + return null; + }} + + + ); + } +} + + ReactDOM.render( + , + document.getElementById("test-app"), +); diff --git a/types/react-virtualized-auto-sizer/tsconfig.json b/types/react-virtualized-auto-sizer/tsconfig.json new file mode 100644 index 0000000000..0d65a828c5 --- /dev/null +++ b/types/react-virtualized-auto-sizer/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "react-virtualized-auto-sizer-tests.tsx" + ] +} diff --git a/types/react-virtualized-auto-sizer/tslint.json b/types/react-virtualized-auto-sizer/tslint.json new file mode 100644 index 0000000000..4f44991c3c --- /dev/null +++ b/types/react-virtualized-auto-sizer/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-empty-interface": false + } +}