mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Adding types for react-window-size (#29507)
This commit is contained in:
parent
d694e947c2
commit
d8ca2bf318
16
types/react-window-size/index.d.ts
vendored
Normal file
16
types/react-window-size/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for react-window-size 1.2
|
||||
// Project: https://github.com/finnfiddle/react-window-size
|
||||
// Definitions by: Jake Richards <https://github.com/jakejrichards>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { ComponentType } from 'react';
|
||||
|
||||
export interface WindowSizeProps {
|
||||
windowHeight: number;
|
||||
windowWidth: number;
|
||||
}
|
||||
|
||||
export default function<T>(
|
||||
ComposedComponent: ComponentType<T & WindowSizeProps>,
|
||||
): ComponentType<T>;
|
||||
23
types/react-window-size/react-window-size-tests.tsx
Normal file
23
types/react-window-size/react-window-size-tests.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import * as React from 'react';
|
||||
import windowSize, { WindowSizeProps } from 'react-window-size';
|
||||
|
||||
interface TestProps {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
type TestInnerProps = TestProps & WindowSizeProps;
|
||||
|
||||
const TestComponent: React.ComponentType<TestInnerProps> = ({ foo, windowHeight, windowWidth }) => {
|
||||
foo; // $ExpectType string
|
||||
windowHeight; // $ExpectType number
|
||||
windowWidth; // $ExpectType number
|
||||
return (
|
||||
<div>
|
||||
<p>Foo: {foo}</p>
|
||||
<p>Window height: {windowHeight}</p>
|
||||
<p>Window width: {windowWidth}</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
windowSize(TestComponent); // $ExpectType ComponentType<TestProps>
|
||||
24
types/react-window-size/tsconfig.json
Normal file
24
types/react-window-size/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-window-size-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-window-size/tslint.json
Normal file
1
types/react-window-size/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user