Add types for react-relative-portal (#45182)

* generate typings for react-relative-portal

* implement types and add tests
This commit is contained in:
Andy Katz 2020-06-03 20:13:22 -05:00 committed by GitHub
parent 6d0efb9414
commit 5ca78f269e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 0 deletions

23
types/react-relative-portal/index.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
// Type definitions for react-relative-portal 1.8
// Project: https://github.com/smartprogress/react-relative-portal#readme
// Definitions by: Andy Katz <https://github.com/katz12>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as React from 'react';
declare class RelativePortal extends React.Component<RelativePortal.Props> {}
declare namespace RelativePortal {
interface Props {
children: React.ReactNode;
className?: string;
component: string;
fullWidth?: boolean;
left?: number;
onOutClick?: () => void;
right?: number;
top?: number;
}
}
export = RelativePortal;

View File

@ -0,0 +1,12 @@
import * as React from 'react';
import RelativePortal = require('react-relative-portal');
<React.Fragment>
<RelativePortal component="div">
<div>portalled content</div>
</RelativePortal>
<RelativePortal component="div" className="portal" fullWidth left={1} onOutClick={() => {}} right={2} top={3}>
<div>portalled content</div>
</RelativePortal>
</React.Fragment>;

View File

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

View File

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