diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts new file mode 100644 index 0000000000..9480f1aef0 --- /dev/null +++ b/types/react-router-hash-link/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for react-router-hash-link 1.2 +// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Sam Baeck +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import { LinkProps, NavLinkProps } from 'react-router-dom'; + +export interface HashLinkProps extends LinkProps { + smooth?: boolean; + scroll?: (element: HTMLElement) => void; +} + +export class HashLink extends React.Component {} + +export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {} + +export class NavHashLink extends React.Component {} diff --git a/types/react-router-hash-link/react-router-hash-link-tests.tsx b/types/react-router-hash-link/react-router-hash-link-tests.tsx new file mode 100644 index 0000000000..4c64a1b5c3 --- /dev/null +++ b/types/react-router-hash-link/react-router-hash-link-tests.tsx @@ -0,0 +1,24 @@ +import * as H from 'history'; +import * as React from 'react'; +import { match } from 'react-router'; +import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link'; + +interface Props extends NavHashLinkProps { + extraProp: string; +} + +const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; + +export default function(props: Props) { + const {extraProp, ...rest} = props; + const isActive = getIsActive(extraProp); + return ( + + ); +} + +; + +const acceptRef = (node: HTMLAnchorElement | null) => { +}; +; diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json new file mode 100644 index 0000000000..fc830ac41d --- /dev/null +++ b/types/react-router-hash-link/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-hash-link-tests.tsx" + ] +} diff --git a/types/react-router-hash-link/tslint.json b/types/react-router-hash-link/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-router-hash-link/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }