From 74b6a1fcb401831d9486cdaca0a7c25fbd75c536 Mon Sep 17 00:00:00 2001 From: Joakim Unge Date: Thu, 30 Jan 2020 22:18:43 +0100 Subject: [PATCH] feat: add type definitions for react-router-tabs (#41981) --- types/react-router-tabs/index.d.ts | 36 +++++++++++++++++++ .../react-router-tabs-tests.ts | 4 +++ types/react-router-tabs/tsconfig.json | 16 +++++++++ types/react-router-tabs/tslint.json | 1 + 4 files changed, 57 insertions(+) create mode 100644 types/react-router-tabs/index.d.ts create mode 100644 types/react-router-tabs/react-router-tabs-tests.ts create mode 100644 types/react-router-tabs/tsconfig.json create mode 100644 types/react-router-tabs/tslint.json diff --git a/types/react-router-tabs/index.d.ts b/types/react-router-tabs/index.d.ts new file mode 100644 index 0000000000..55a4129d58 --- /dev/null +++ b/types/react-router-tabs/index.d.ts @@ -0,0 +1,36 @@ +// Type definitions for react-router-tabs 1.3 +// Project: https://github.com/chacestew/react-router-tabs#readme +// Definitions by: Joakim Unge +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Route, Link, RouteProps } from 'react-router-dom'; +import { ReactNode } from 'react'; + +export type AriaCurrent = 'page' | 'step' | 'location' | 'date' | 'time' | 'true'; + +export interface NavTabProps { + to: string | object; + replace?: boolean; + exact?: boolean; + strict?: boolean; + activeClassName?: string; + className?: string; + activeStyle?: object; + style?: object; + 'aria-current'?: AriaCurrent; + disabled?: boolean; +} + +export interface RoutedTabsProps { + startPathWith?: string; + className?: string; + style?: object; + tabClassName?: string; + activeTabClassName?: string; + tabStyle?: object; + activeTabStyle?: object; + children?: ReactNode; +} + +export function NavTab(props: NavTabProps): Route; +export function RoutedTabs(props: RoutedTabsProps): ReactNode; diff --git a/types/react-router-tabs/react-router-tabs-tests.ts b/types/react-router-tabs/react-router-tabs-tests.ts new file mode 100644 index 0000000000..2a16b067d6 --- /dev/null +++ b/types/react-router-tabs/react-router-tabs-tests.ts @@ -0,0 +1,4 @@ +import { NavTab, RoutedTabs } from 'react-router-tabs'; + +NavTab({ to: 'path' }); // $ExpectType Route +RoutedTabs({}); // $ExpectType ReactNode diff --git a/types/react-router-tabs/tsconfig.json b/types/react-router-tabs/tsconfig.json new file mode 100644 index 0000000000..11da3efbc1 --- /dev/null +++ b/types/react-router-tabs/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "react-router-tabs-tests.ts"] +} diff --git a/types/react-router-tabs/tslint.json b/types/react-router-tabs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-router-tabs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }